drm/etnaviv: add missing quirks for GC300
Subsystems (26)
Sasha Levin
maintainerPATCH 22/73 hamradio: baycom_epp: Fix return type of baycom_send_packet()
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit c5733e5b15d91ab679646ec3149e192996a27d5d ]
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/net/hamradio/baycom_epp.c:1119:25: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.ndo_start_xmit = baycom_send_packet,
^~~~~~~~~~~~~~~~~~
1 error generated.
->ndo_start_xmit() in 'struct net_device_ops' expects a return type of 'netdev_tx_t', not 'int'. Adjust the return type of baycom_send_packet() to match the prototype's to resolve the warning and CFI failure.
--- drivers/net/hamradio/baycom_epp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/hamradio/baycom_epp.c +1 -1
@@ -758,7 +758,7 @@ static void epp_bh(struct work_struct *work)* ===================== network driver interface ========================= */ -static int baycom_send_packet (struct sk_buff *skb,struct net_device *dev) +static netdev_tx_t baycom_send_packet (struct sk_buff *skb,struct net_device *dev) {struct baycom_state *bc =netdev_priv (dev);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 1/73 drm/etnaviv: add missing quirks for GC300
From: Doug Brown <[email protected]>
[ Upstream commit cc7d3fb446a91f24978a6aa59cbb578f92e22242 ]
The GC300's features register doesn't specify that a 2D pipe is available, and like the GC600, its idle register reports zero bits where modules aren't present.
--- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +9 -2
@@ -416,6 +416,12 @@ static void etnaviv_hw_identify(struct etnaviv_gpu *gpu)if (gpu->identity.model == chipModel_GC700) gpu->identity.features &= ~chipFeatures_FAST_CLEAR; +/* These models/revisions don't have the 2D pipe bit */ +if ((gpu->identity.model == chipModel_GC500 && + gpu->identity.revision <=2 ) || + gpu->identity.model == chipModel_GC300) + gpu->identity.features |= chipFeatures_PIPE_2D; + if ((gpu->identity.model == chipModel_GC500 && gpu->identity.revision < 2) || (gpu->identity.model == chipModel_GC300 &&
@@ -449,8 +455,9 @@ static void etnaviv_hw_identify(struct etnaviv_gpu *gpu)gpu_read (gpu,VIVS_HI_CHIP_MINOR_FEATURE_5 ); } -/* GC600 idle register reports zero bits where modules aren't present */ -if (gpu->identity.model == chipModel_GC600) +/* GC600/300 idle register reports zero bits where modules aren't present */ +if (gpu->identity.model == chipModel_GC600 || + gpu->identity.model == chipModel_GC300) gpu->idle_mask =VIVS_HI_IDLE_STATE_TX |VIVS_HI_IDLE_STATE_RA | VIVS_HI_IDLE_STATE_SE |
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 10/73 drm/amd/display: prevent memory leak
From: gehao <[email protected]>
[ Upstream commit d232afb1f3417ae8194ccf19ad3a8360e70e104e ]
In dce6(0,1,4)_create_resource_pool and dce80_create_resource_pool the allocated memory should be released if construct pool fails.
--- drivers/gpu/drm/amd/display/dc/dce60/dce60_resource.c | 3 +++ drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c | 2 ++ 2 files changed, 5 insertions(+)
drivers/gpu/drm/amd/display/dc/dce60/dce60_resource.c +3 -0
@@ -1128,6 +1128,7 @@ struct resource_pool *dce60_create_resource_pool(if (dce60_construct (num_virtual_links, dc, pool))return &pool->base; +kfree (pool);BREAK_TO_DEBUGGER ();return NULL ; }
@@ -1325,6 +1326,7 @@ struct resource_pool *dce61_create_resource_pool(if (dce61_construct (num_virtual_links, dc, pool))return &pool->base; +kfree (pool);BREAK_TO_DEBUGGER ();return NULL ; }
@@ -1518,6 +1520,7 @@ struct resource_pool *dce64_create_resource_pool(if (dce64_construct (num_virtual_links, dc, pool))return &pool->base; +kfree (pool);BREAK_TO_DEBUGGER ();return NULL ; }
drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c +2 -0
@@ -1137,6 +1137,7 @@ struct resource_pool *dce80_create_resource_pool(if (dce80_construct (num_virtual_links, dc, pool))return &pool->base; +kfree (pool);BREAK_TO_DEBUGGER ();return NULL ; }
@@ -1336,6 +1337,7 @@ struct resource_pool *dce81_create_resource_pool(if (dce81_construct (num_virtual_links, dc, pool))return &pool->base; +kfree (pool);BREAK_TO_DEBUGGER ();return NULL ; }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 9/73 wifi: ath10k: Delay the unmapping of the buffer
In reply to Sasha LevinFrom: Youghandhar Chintala <[email protected]>
[ Upstream commit acd4324e5f1f11351630234297f95076f0ac9a2f ]
On WCN3990, we are seeing a rare scenario where copy engine hardware is sending a copy complete interrupt to the host driver while still processing the buffer that the driver has sent, this is leading into an SMMU fault triggering kernel panic. This is happening on copy engine channel 3 (CE3) where the driver normally enqueues WMI commands to the firmware. Upon receiving a copy complete interrupt, host driver will immediately unmap and frees the buffer presuming that hardware has processed the buffer. In the issue case, upon receiving copy complete interrupt, host driver will unmap and free the buffer but since hardware is still accessing the buffer (which in this case got unmapped in parallel), SMMU hardware will trigger an SMMU fault resulting in a kernel panic.
In order to avoid this, as a work around, add a delay before unmapping the copy engine source DMA buffer. This is conditionally done for WCN3990 and only for the CE3 channel where issue is seen.
Below is the crash signature:
wifi smmu error: kernel: [ 10.120965] arm-smmu 15000000.iommu: Unhandled context fault: fsr=0x402, iova=0x7fdfd8ac0, fsynr=0x500003,cbfrsynra=0xc1, cb=6 arm-smmu 15000000.iommu: Unhandled context fault:fsr=0x402, iova=0x7fe06fdc0, fsynr=0x710003, cbfrsynra=0xc1, cb=6 qcom-q6v5-mss 4080000.remoteproc: fatal error
received: err_qdi.c:1040:EF:wlan_process:0x1:WLAN RT:0x2091:
cmnos_thread.c:3998:Asserted in copy_engine.c:AXI_ERROR_DETECTED:2149 remoteproc remoteproc0: crash detected in 4080000.remoteproc: type fatal error <3> remoteproc remoteproc0:
handling crash #1 in 4080000.remoteproc
pc : __arm_lpae_unmap+0x500/0x514 lr : __arm_lpae_unmap+0x4bc/0x514
sp : ffffffc011ffb530
x29: ffffffc011ffb590 x28: 0000000000000000
x27: 0000000000000000 x26: 0000000000000004
x25: 0000000000000003 x24: ffffffc011ffb890
x23: ffffffa762ef9be0 x22: ffffffa77244ef00
x21: 0000000000000009 x20: 00000007fff7c000
x19: 0000000000000003 x18: 0000000000000000
x17: 0000000000000004 x16: ffffffd7a357d9f0
x15: 0000000000000000 x14: 00fd5d4fa7ffffff
x13: 000000000000000e x12: 0000000000000000
x11: 00000000ffffffff x10: 00000000fffffe00
x9 : 000000000000017c x8 : 000000000000000c
x7 : 0000000000000000 x6 : ffffffa762ef9000
x5 : 0000000000000003 x4 : 0000000000000004
x3 : 0000000000001000 x2 : 00000007fff7c000
x1 : ffffffc011ffb890 x0 : 0000000000000000 Call trace:
__arm_lpae_unmap+0x500/0x514 __arm_lpae_unmap+0x4bc/0x514 __arm_lpae_unmap+0x4bc/0x514 arm_lpae_unmap_pages+0x78/0xa4 arm_smmu_unmap_pages+0x78/0x104 __iommu_unmap+0xc8/0x1e4 iommu_unmap_fast+0x38/0x48 __iommu_dma_unmap+0x84/0x104 iommu_dma_free+0x34/0x50 dma_free_attrs+0xa4/0xd0 ath10k_htt_rx_free+0xc4/0xf4 [ath10k_core] ath10k_core_stop+0x64/0x7c [ath10k_core] ath10k_halt+0x11c/0x180 [ath10k_core] ath10k_stop+0x54/0x94 [ath10k_core] drv_stop+0x48/0x1c8 [mac80211] ieee80211_do_open+0x638/0x77c [mac80211] ieee80211_open+0x48/0x5c [mac80211] __dev_open+0xb4/0x174 __dev_change_flags+0xc4/0x1dc dev_change_flags+0x3c/0x7c devinet_ioctl+0x2b4/0x580 inet_ioctl+0xb0/0x1b4 sock_do_ioctl+0x4c/0x16c compat_ifreq_ioctl+0x1cc/0x35c compat_sock_ioctl+0x110/0x2ac __arm64_compat_sys_ioctl+0xf4/0x3e0 el0_svc_common+0xb4/0x17c el0_svc_compat_handler+0x2c/0x58 el0_svc_compat+0x8/0x2c
Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.2.0-01387-QCAHLSWMTPLZ-1
--- drivers/net/wireless/ath/ath10k/core.c | 16 ++++++++++++++++ drivers/net/wireless/ath/ath10k/htc.c | 9 +++++++++ drivers/net/wireless/ath/ath10k/hw.h | 2 ++ 3 files changed, 27 insertions(+)
drivers/net/wireless/ath/ath10k/core.c +16 -0
@@ -99,6 +99,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA988X_HW_2_0_VERSION,
@@ -138,6 +139,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA9887_HW_1_0_VERSION,
@@ -178,6 +180,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA6174_HW_3_2_VERSION,
@@ -213,6 +216,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = true, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA6174_HW_2_1_VERSION,
@@ -252,6 +256,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA6174_HW_2_1_VERSION,
@@ -291,6 +296,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA6174_HW_3_0_VERSION,
@@ -330,6 +336,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA6174_HW_3_2_VERSION,
@@ -373,6 +380,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = true, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA99X0_HW_2_0_DEV_VERSION,
@@ -418,6 +426,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA9984_HW_1_0_DEV_VERSION,
@@ -470,6 +479,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA9888_HW_2_0_DEV_VERSION,
@@ -519,6 +529,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA9377_HW_1_0_DEV_VERSION,
@@ -558,6 +569,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA9377_HW_1_1_DEV_VERSION,
@@ -599,6 +611,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA9377_HW_1_1_DEV_VERSION,
@@ -631,6 +644,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = QCA4019_HW_1_0_DEV_VERSION,
@@ -677,6 +691,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = false, .hw_restart_disconnect = false, .use_fw_tx_credits = true, + .delay_unmap_buffer = false, }, { .id = WCN3990_HW_1_0_DEV_VERSION,
@@ -709,6 +724,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .dynamic_sar_support = true, .hw_restart_disconnect = true, .use_fw_tx_credits = false, + .delay_unmap_buffer = true, }, };
drivers/net/wireless/ath/ath10k/htc.c +9 -0
@@ -56,6 +56,15 @@ void ath10k_htc_notify_tx_completion(struct ath10k_htc_ep *ep,ath10k_dbg (ar,ATH10K_DBG_HTC ,"%s: ep %d skb %pK\n" , __func__, ep->eid, skb); +/* A corner case where the copy completion is reaching to host but still +* copy engine is processing it due to which host unmaps corresponding +* memory and causes SMMU fault, hence as workaround adding delay +* the unmapping memory to avoid SMMU faults. +*/ +if (ar->hw_params.delay_unmap_buffer && + ep->ul_pipe_id ==3 ) +mdelay (2 ); + hdr = (struct ath10k_htc_hdr *)skb->data;ath10k_htc_restore_tx_skb (ep->htc, skb);
drivers/net/wireless/ath/ath10k/hw.h +2 -0
@@ -637,6 +637,8 @@ struct ath10k_hw_params {bool hw_restart_disconnect;bool use_fw_tx_credits; + +bool delay_unmap_buffer; };struct htt_resp ;
Signature · 7 lines
2.35.1 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Sasha Levin
maintainerPATCH 12/73 Revert "drm/amd/display: Limit max DSC target bpp for specific monitors"
In reply to Sasha LevinFrom: Hamza Mahfooz <[email protected]>
[ Upstream commit 6803dfd3a69ccb318772463a86e40929fd4fbac7 ]
This reverts commit 55eea8ef98641f6e1e1c202bd3a49a57c1dd4059.
This quirk is now handled in the DRM core, so we can drop all of the internal code that was added to handle it.
--- .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 35 ------------------- 1 file changed, 35 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +0 -35
@@ -41,39 +41,6 @@#include "dm_helpers.h" #include "ddc_service_types.h" -struct monitor_patch_info { -unsigned int manufacturer_id; -unsigned int product_id; -void (*patch_func)(struct dc_edid_caps *edid_caps,unsigned int param); -unsigned int patch_param; -}; -static void set_max_dsc_bpp_limit (struct dc_edid_caps *edid_caps,unsigned int param); - -static const struct monitor_patch_info monitor_patch_table[] = { -{0x6D1E ,0x5BBF , set_max_dsc_bpp_limit,15 }, -{0x6D1E ,0x5B9A , set_max_dsc_bpp_limit,15 }, -}; - -static void set_max_dsc_bpp_limit (struct dc_edid_caps *edid_caps,unsigned int param) -{ -if (edid_caps) - edid_caps->panel_patch.max_dsc_target_bpp_limit = param; -} - -static int amdgpu_dm_patch_edid_caps (struct dc_edid_caps *edid_caps) -{ -int i, ret =0 ; - -for (i =0 ; i <ARRAY_SIZE (monitor_patch_table); i++) -if ((edid_caps->manufacturer_id == monitor_patch_table[i].manufacturer_id) - && (edid_caps->product_id == monitor_patch_table[i].product_id)) { - monitor_patch_table[i].patch_func (edid_caps, monitor_patch_table[i].patch_param); - ret++; - } - -return ret; -} -/* dm_helpers_parse_edid_caps * * Parse edid caps
@@ -148,8 +115,6 @@ enum dc_edid_status dm_helpers_parse_edid_caps(kfree (sads);kfree (sadb); -amdgpu_dm_patch_edid_caps (edid_caps); -return result; }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 11/73 drm/edid: add a quirk for two LG monitors to get them to work on 10bpc
In reply to Sasha LevinFrom: Hamza Mahfooz <[email protected]>
[ Upstream commit aa193f7eff8ff753577351140b8af13b76cdc7c2 ]
The LG 27GP950 and LG 27GN950 have visible display corruption when trying to use 10bpc modes. So, to fix this, cap their maximum DSC target bitrate to 15bpp.
--- drivers/gpu/drm/drm_edid.c | 12 ++++++++++++ include/drm/drm_connector.h | 6 ++++++ 2 files changed, 18 insertions(+)
drivers/gpu/drm/drm_edid.c +12 -0
@@ -87,6 +87,8 @@ static int oui(u8 first, u8 second, u8 third)#define EDID_QUIRK_FORCE_10BPC (1 << 11)/* Non desktop display (i.e. HMD) */ #define EDID_QUIRK_NON_DESKTOP (1 << 12) +/* Cap the DSC target bitrate to 15bpp */ +#define EDID_QUIRK_CAP_DSC_15BPP (1 << 13)#define MICROSOFT_IEEE_OUI 0xca125c
@@ -147,6 +149,12 @@ static const struct edid_quirk {EDID_QUIRK ('F' ,'C' ,'M' ,13600 ,EDID_QUIRK_PREFER_LARGE_75 |EDID_QUIRK_DETAILED_IN_CM ), +/* LG 27GP950 */ +EDID_QUIRK ('G' ,'S' ,'M' ,0x5bbf ,EDID_QUIRK_CAP_DSC_15BPP ), + +/* LG 27GN950 */ +EDID_QUIRK ('G' ,'S' ,'M' ,0x5b9a ,EDID_QUIRK_CAP_DSC_15BPP ), +/* LGD panel of HP zBook 17 G2, eDP 10 bpc, but reports unknown bpc */ EDID_QUIRK('L', 'G', 'D', 764, EDID_QUIRK_FORCE_10BPC),
@@ -6116,6 +6124,7 @@ static void drm_reset_display_info(struct drm_connector *connector) info->mso_stream_count =0 ; info->mso_pixel_overlap =0 ; + info->max_dsc_bpp =0 ; } static u32 update_display_info(struct drm_connector *connector,
@@ -6202,6 +6211,9 @@ static u32 update_display_info(struct drm_connector *connector, info->non_desktop = true; } +if (quirks &EDID_QUIRK_CAP_DSC_15BPP ) + info->max_dsc_bpp =15 ; +return quirks; }
include/drm/drm_connector.h +6 -0
@@ -635,6 +635,12 @@ struct drm_display_info {* @mso_pixel_overlap: eDP MSO segment pixel overlap, 0-8 pixels. */ u8 mso_pixel_overlap; + +/** +* @max_dsc_bpp: Maximum DSC target bitrate, if it is set to 0 the +* monitor's default value is used instead. +*/ +u32 max_dsc_bpp; }; int drm_display_info_set_bus_formats(struct drm_display_info *info,
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 13/73 drm/rockchip: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync()
In reply to Sasha LevinFrom: Yuan Can <[email protected]>
[ Upstream commit e3558747ebe15306e6d0b75bd6d211436be4a7d5 ]
Replace pm_runtime_get_sync() with pm_runtime_resume_and_get() to avoid device usage counter leak.
--- drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 2 +- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 4 ++-- drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +1 -1
@@ -1201,7 +1201,7 @@ static int dw_mipi_dsi_dphy_power_on(struct phy *phy)return i; } - ret =pm_runtime_get_sync (dsi->dev); + ret =pm_runtime_resume_and_get (dsi->dev);if (ret <0 ) {DRM_DEV_ERROR (dsi->dev,"failed to enable device: %d\n" , ret);return ret;
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +2 -2
@@ -605,7 +605,7 @@ static int vop_enable(struct drm_crtc *crtc, struct drm_crtc_state *old_state)struct vop *vop =to_vop (crtc);int ret, i; - ret =pm_runtime_get_sync (vop->dev); + ret =pm_runtime_resume_and_get (vop->dev);if (ret <0 ) {DRM_DEV_ERROR (vop->dev,"failed to get pm runtime: %d\n" , ret);return ret;
@@ -1953,7 +1953,7 @@ static int vop_initial(struct vop *vop)return PTR_ERR (vop->dclk); } - ret =pm_runtime_get_sync (vop->dev); + ret =pm_runtime_resume_and_get (vop->dev);if (ret <0 ) {DRM_DEV_ERROR (vop->dev,"failed to get pm runtime: %d\n" , ret);return ret;
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +1 -1
@@ -823,7 +823,7 @@ static void vop2_enable(struct vop2 *vop2) {int ret; - ret =pm_runtime_get_sync (vop2->dev); + ret =pm_runtime_resume_and_get (vop2->dev);if (ret <0 ) {drm_err (vop2->drm,"failed to get pm runtime: %d\n" , ret);return ;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 19/73 drm/meson: Fix return type of meson_encoder_cvbs_mode_valid()
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 6c4e4d35203301906afb53c6d1e1302d4c793c05 ]
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/gpu/drm/meson/meson_encoder_cvbs.c:211:16: error: incompatible function pointer types initializing 'enum drm_mode_status (*)(struct drm_bridge *, const struct drm_display_info *, const struct drm_display_mode *)' with an expression of type 'int (struct drm_bridge *, const struct drm_display_info *, const struct drm_display_mode *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.mode_valid = meson_encoder_cvbs_mode_valid,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
->mode_valid() in 'struct drm_bridge_funcs' expects a return type of 'enum drm_mode_status', not 'int'. Adjust the return type of meson_encoder_cvbs_mode_valid() to match the prototype's to resolve the warning and CFI failure.
--- drivers/gpu/drm/meson/meson_encoder_cvbs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/meson/meson_encoder_cvbs.c +4 -3
@@ -116,9 +116,10 @@ static int meson_encoder_cvbs_get_modes(struct drm_bridge *bridge,return i; } -static int meson_encoder_cvbs_mode_valid (struct drm_bridge *bridge, -const struct drm_display_info *display_info, -const struct drm_display_mode *mode) +static enum drm_mode_status +meson_encoder_cvbs_mode_valid (struct drm_bridge *bridge, +const struct drm_display_info *display_info, +const struct drm_display_mode *mode) {if (meson_cvbs_get_mode (mode))return MODE_OK ;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 14/73 blk-mq: avoid double ->queue_rq() because of early timeout
In reply to Sasha LevinFrom: David Jeffery <[email protected]>
[ Upstream commit 82c229476b8f6afd7e09bc4dc77d89dc19ff7688 ]
David Jeffery found one double ->queue_rq() issue, so far it can be triggered in VM use case because of long vmexit latency or preempt latency of vCPU pthread or long page fault in vCPU pthread, then block IO req could be timed out before queuing the request to hardware but after calling blk_mq_start_request() during ->queue_rq(), then timeout handler may handle it by requeue, then double ->queue_rq() is caused, and kernel panic.
So far, it is driver's responsibility to cover the race between timeout and completion, so it seems supposed to be solved in driver in theory, given driver has enough knowledge.
But it is really one common problem, lots of driver could have similar issue, and could be hard to fix all affected drivers, even it isn't easy for driver to handle the race. So David suggests this patch by draining in-progress ->queue_rq() for solving this issue.
--- block/blk-mq.c | 56 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 12 deletions(-)
block/blk-mq.c +44 -12
@@ -1442,7 +1442,13 @@ static void blk_mq_rq_timed_out(struct request *req)blk_add_timer (req); } -static bool blk_mq_req_expired (struct request *rq,unsigned long *next) +struct blk_expired_data { +bool has_timedout_rq; +unsigned long next; +unsigned long timeout_start; +}; + +static bool blk_mq_req_expired (struct request *rq,struct blk_expired_data *expired) {unsigned long deadline;
@@ -1452,13 +1458,13 @@ static bool blk_mq_req_expired(struct request *rq, unsigned long *next)return false; deadline =READ_ONCE (rq->deadline); -if (time_after_eq (jiffies, deadline)) +if (time_after_eq (expired->timeout_start, deadline))return true; -if (*next ==0 ) - *next = deadline; -else if (time_after (*next, deadline)) - *next = deadline; +if (expired->next ==0 ) + expired->next = deadline; +else if (time_after (expired->next, deadline)) + expired->next = deadline;return false; }
@@ -1472,7 +1478,7 @@ void blk_mq_put_rq_ref(struct request *rq)static bool blk_mq_check_expired (struct request *rq,void *priv) { -unsigned long *next = priv; +struct blk_expired_data *expired = priv;/* * blk_mq_queue_tag_busy_iter() has locked the request, so it cannot
@@ -1481,7 +1487,18 @@ static bool blk_mq_check_expired(struct request *rq, void *priv)* it was completed and reallocated as a new request after returning * from blk_mq_check_expired(). */ -if (blk_mq_req_expired (rq, next)) +if (blk_mq_req_expired (rq, expired)) { + expired->has_timedout_rq = true; +return false; + } +return true; +} + +static bool blk_mq_handle_expired (struct request *rq,void *priv) +{ +struct blk_expired_data *expired = priv; + +if (blk_mq_req_expired (rq, expired))blk_mq_rq_timed_out (rq);return true; }
@@ -1490,7 +1507,9 @@ static void blk_mq_timeout_work(struct work_struct *work) {struct request_queue *q = container_of(work, struct request_queue, timeout_work); -unsigned long next =0 ; +struct blk_expired_data expired = { + .timeout_start = jiffies, + };struct blk_mq_hw_ctx *hctx;unsigned long i;
@@ -1510,10 +1529,23 @@ static void blk_mq_timeout_work(struct work_struct *work)if (!percpu_ref_tryget (&q->q_usage_counter))return ; -blk_mq_queue_tag_busy_iter (q, blk_mq_check_expired, &next); +/* check if there is any timed-out request */ +blk_mq_queue_tag_busy_iter (q, blk_mq_check_expired, &expired); +if (expired.has_timedout_rq) { +/* +* Before walking tags, we must ensure any submit started +* before the current time has finished. Since the submit +* uses srcu or rcu, wait for a synchronization point to +* ensure all running submits have finished +*/ +blk_mq_wait_quiesce_done (q); + + expired.next =0 ; +blk_mq_queue_tag_busy_iter (q, blk_mq_handle_expired, &expired); + } -if (next !=0 ) { -mod_timer (&q->timeout, next); +if (expired.next !=0 ) { +mod_timer (&q->timeout, expired.next); }else {/* * Request timeouts are handled as a forward rolling timer. If
Signature · 6 lines
2.35.1 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Sasha Levin
maintainerPATCH 6/73 ASoC: codecs: rt298: Add quirk for KBL-R RVP platform
In reply to Sasha LevinFrom: Amadeusz Sławiński <[email protected]>
[ Upstream commit 953dbd1cef18ce9ac0d69c1bd735b929fe52a17e ]
KBL-R RVP platforms also use combojack, so we need to enable that configuration for them.
--- sound/soc/codecs/rt298.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/codecs/rt298.c +7 -0
@@ -1166,6 +1166,13 @@ static const struct dmi_system_id force_combo_jack_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "Geminilake") } }, + { + .ident = "Intel Kabylake R RVP", + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Intel Corporation" ), + DMI_MATCH(DMI_PRODUCT_NAME, "Kabylake Client platform") + } + }, { } };
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 21/73 net: ethernet: ti: Fix return type of netcp_ndo_start_xmit()
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 63fe6ff674a96cfcfc0fa8df1051a27aa31c70b4 ]
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/net/ethernet/ti/netcp_core.c:1944:21: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.ndo_start_xmit = netcp_ndo_start_xmit,
^~~~~~~~~~~~~~~~~~~~
1 error generated.
->ndo_start_xmit() in 'struct net_device_ops' expects a return type of 'netdev_tx_t', not 'int'. Adjust the return type of netcp_ndo_start_xmit() to match the prototype's to resolve the warning and CFI failure.
--- drivers/net/ethernet/ti/netcp_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/ti/netcp_core.c +1 -1
@@ -1261,7 +1261,7 @@ static int netcp_tx_submit_skb(struct netcp_intf *netcp, }/* Submit the packet */ -static int netcp_ndo_start_xmit (struct sk_buff *skb,struct net_device *ndev) +static netdev_tx_t netcp_ndo_start_xmit (struct sk_buff *skb,struct net_device *ndev) {struct netcp_intf *netcp =netdev_priv (ndev);struct netcp_stats *tx_stats = &netcp->stats;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 2/73 media: imx-jpeg: Disable useless interrupt to avoid kernel panic
In reply to Sasha LevinFrom: Ming Qian <[email protected]>
[ Upstream commit c3720e65c9013a7b2a5dbb63e6bf6d74a35dd894 ]
There is a hardware bug that the interrupt STMBUF_HALF may be triggered after or when disable interrupt.
It may led to unexpected kernel panic.
And interrupt STMBUF_HALF and STMBUF_RTND have no other effect. So disable them and the unused interrupts.
meanwhile clear the interrupt status when disable interrupt.
--- drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c +3 -1
@@ -76,12 +76,14 @@ void print_wrapper_info(struct device *dev, void __iomem *reg)void mxc_jpeg_enable_irq (void __iomem *reg,int slot) { -writel (0xFFFFFFFF , reg +MXC_SLOT_OFFSET (slot,SLOT_IRQ_EN )); +writel (0xFFFFFFFF , reg +MXC_SLOT_OFFSET (slot,SLOT_STATUS )); +writel (0xF0C , reg +MXC_SLOT_OFFSET (slot,SLOT_IRQ_EN )); }void mxc_jpeg_disable_irq (void __iomem *reg,int slot) {writel (0x0 , reg +MXC_SLOT_OFFSET (slot,SLOT_IRQ_EN )); +writel (0xFFFFFFFF , reg +MXC_SLOT_OFFSET (slot,SLOT_STATUS )); }void mxc_jpeg_sw_reset (void __iomem *reg)
Signature · 7 lines
2.35.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 7/73 ASoC: Intel: avs: Add quirk for KBL-R RVP platform
In reply to Sasha LevinFrom: Amadeusz Sławiński <[email protected]>
[ Upstream commit 9d0737fa0e7530313634c0ecd75f09a95ba8d44a ]
KBL-R RVPs contain built-in rt298 codec which requires different PLL clock and .dai_fmt configuration than seen on other boards.
--- sound/soc/intel/avs/boards/rt298.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
sound/soc/intel/avs/boards/rt298.c +22 -2
@@ -6,6 +6,7 @@// Amadeusz Slawinski <[email protected]> // +#include <linux/dmi.h> #include <linux/module.h> #include <sound/jack.h> #include <sound/pcm.h>
@@ -14,6 +15,16 @@#include <sound/soc-acpi.h> #include "../../../codecs/rt298.h" +static const struct dmi_system_id kblr_dmi_table[] = { + { + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Intel Corporation" ), +DMI_MATCH (DMI_BOARD_NAME ,"Kabylake R DDR4 RVP" ), + }, + }, + {} +}; +static const struct snd_kcontrol_new card_controls[] = {SOC_DAPM_PIN_SWITCH ("Headphone Jack" ),SOC_DAPM_PIN_SWITCH ("Mic Jack" ),
@@ -96,9 +107,15 @@ avs_rt298_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_param {struct snd_soc_pcm_runtime *rtd = substream->private_data;struct snd_soc_dai *codec_dai =asoc_rtd_to_codec (rtd,0 ); +unsigned int clk_freq;int ret; - ret =snd_soc_dai_set_sysclk (codec_dai,RT298_SCLK_S_PLL ,19200000 ,SND_SOC_CLOCK_IN ); +if (dmi_first_match (kblr_dmi_table)) + clk_freq =24000000 ; +else + clk_freq =19200000 ; + + ret =snd_soc_dai_set_sysclk (codec_dai,RT298_SCLK_S_PLL , clk_freq,SND_SOC_CLOCK_IN );if (ret <0 )dev_err (rtd->dev,"Set codec sysclk failed: %d\n" , ret);
@@ -139,7 +156,10 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in dl->platforms = platform; dl->num_platforms =1 ; dl->id =0 ; - dl->dai_fmt =SND_SOC_DAIFMT_DSP_A |SND_SOC_DAIFMT_NB_NF |SND_SOC_DAIFMT_CBS_CFS ; +if (dmi_first_match (kblr_dmi_table)) + dl->dai_fmt =SND_SOC_DAIFMT_I2S |SND_SOC_DAIFMT_NB_NF |SND_SOC_DAIFMT_CBS_CFS ; +else + dl->dai_fmt =SND_SOC_DAIFMT_DSP_A |SND_SOC_DAIFMT_NB_NF |SND_SOC_DAIFMT_CBS_CFS ; dl->init = avs_rt298_codec_init; dl->be_hw_params_fixup = avs_rt298_be_fixup; dl->ops = &avs_rt298_ops;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 25/73 igb: Do not free q_vector unless new one was allocated
In reply to Sasha LevinFrom: Kees Cook <[email protected]>
[ Upstream commit 0668716506ca66f90d395f36ccdaebc3e0e84801 ]
Avoid potential use-after-free condition under memory pressure. If the kzalloc() fails, q_vector will be freed but left in the original adapter->q_vector[v_idx] array position.
--- drivers/net/ethernet/intel/igb/igb_main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/igb/igb_main.c +6 -2
@@ -1202,8 +1202,12 @@ static int igb_alloc_q_vector(struct igb_adapter *adapter,if (!q_vector) { q_vector =kzalloc (size,GFP_KERNEL ); }else if (size >ksize (q_vector)) { -kfree_rcu (q_vector, rcu); - q_vector =kzalloc (size,GFP_KERNEL ); +struct igb_q_vector *new_q_vector; + + new_q_vector =kzalloc (size,GFP_KERNEL ); +if (new_q_vector) +kfree_rcu (q_vector, rcu); + q_vector = new_q_vector; }else {memset (q_vector,0 , size); }
Signature · 6 lines
2.35.1 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Sasha Levin
maintainerPATCH 26/73 drm/amdgpu: Fix type of second parameter in trans_msg() callback
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit f0d0f1087333714ee683cc134a95afe331d7ddd9 ]
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c:412:15: error: incompatible function pointer types initializing 'void (*)(struct amdgpu_device *, u32, u32, u32, u32)' (aka 'void (*)(struct amdgpu_device *, unsigned int, unsigned int, unsigned int, unsigned int)') with an expression of type 'void (struct amdgpu_device *, enum idh_request, u32, u32, u32)' (aka 'void (struct amdgpu_device *, enum idh_request, unsigned int, unsigned int, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict]
.trans_msg = xgpu_ai_mailbox_trans_msg,
^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c:435:15: error: incompatible function pointer types initializing 'void (*)(struct amdgpu_device *, u32, u32, u32, u32)' (aka 'void (*)(struct amdgpu_device *, unsigned int, unsigned int, unsigned int, unsigned int)') with an expression of type 'void (struct amdgpu_device *, enum idh_request, u32, u32, u32)' (aka 'void (struct amdgpu_device *, enum idh_request, unsigned int, unsigned int, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict]
.trans_msg = xgpu_nv_mailbox_trans_msg,
^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
The type of the second parameter in the prototype should be 'enum idh_request' instead of 'u32'. Update it to clear up the warnings.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +4 -1
@@ -75,6 +75,8 @@ struct amdgpu_vf_error_buffer {uint64_t data[AMDGPU_VF_ERROR_ENTRY_SIZE ]; }; +enum idh_request ; +/** * struct amdgpu_virt_ops - amdgpu device virt operations */
@@ -84,7 +86,8 @@ struct amdgpu_virt_ops {int (*req_init_data)(struct amdgpu_device *adev);int (*reset_gpu)(struct amdgpu_device *adev);int (*wait_reset)(struct amdgpu_device *adev); -void (*trans_msg)(struct amdgpu_device *adev,u32 req,u32 data1,u32 data2,u32 data3); +void (*trans_msg)(struct amdgpu_device *adev,enum idh_request req, +u32 data1,u32 data2,u32 data3); };/*
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 27/73 drm/amdgpu: Fix type of second parameter in odn_edit_dpm_table() callback
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit e4d0ef752081e7aa6ffb7ccac11c499c732a2e05 ]
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/gpu/drm/amd/amdgpu/../pm/swsmu/amdgpu_smu.c:3008:29: error: incompatible function pointer types initializing 'int (*)(void *, uint32_t, long *, uint32_t)' (aka 'int (*)(void *, unsigned int, long *, unsigned int)') with an expression of type 'int (void *, enum PP_OD_DPM_TABLE_COMMAND, long *, uint32_t)' (aka 'int (void *, enum PP_OD_DPM_TABLE_COMMAND, long *, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict]
.odn_edit_dpm_table = smu_od_edit_dpm_table,
^~~~~~~~~~~~~~~~~~~~~
1 error generated.
There are only two implementations of ->odn_edit_dpm_table() in 'struct amd_pm_funcs': smu_od_edit_dpm_table() and pp_odn_edit_dpm_table(). One has a second parameter type of 'enum PP_OD_DPM_TABLE_COMMAND' and the other uses 'u32'. Ultimately, smu_od_edit_dpm_table() calls ->od_edit_dpm_table() from 'struct pptable_funcs' and pp_odn_edit_dpm_table() calls ->odn_edit_dpm_table() from 'struct pp_hwmgr_func', which both have a second parameter type of 'enum PP_OD_DPM_TABLE_COMMAND'.
Update the type parameter in both the prototype in 'struct amd_pm_funcs' and pp_odn_edit_dpm_table() to 'enum PP_OD_DPM_TABLE_COMMAND', which cleans up the warning.
--- drivers/gpu/drm/amd/include/kgd_pp_interface.h | 3 ++- drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/include/kgd_pp_interface.h +2 -1
@@ -354,7 +354,8 @@ struct amd_pm_funcs {int (*get_power_profile_mode)(void *handle,char *buf);int (*set_power_profile_mode)(void *handle,long *input,uint32_t size);int (*set_fine_grain_clk_vol)(void *handle,uint32_t type,long *input,uint32_t size); -int (*odn_edit_dpm_table)(void *handle,uint32_t type,long *input,uint32_t size); +int (*odn_edit_dpm_table)(void *handle,enum PP_OD_DPM_TABLE_COMMAND type, +long *input,uint32_t size);int (*set_mp1_state)(void *handle,enum pp_mp1_state mp1_state);int (*smu_i2c_bus_access)(void *handle,bool acquire);int (*gfx_state_change_set)(void *handle,uint32_t state);
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +2 -1
@@ -838,7 +838,8 @@ static int pp_set_fine_grain_clk_vol(void *handle, uint32_t type, long *input, ureturn hwmgr->hwmgr_func->set_fine_grain_clk_vol (hwmgr, type, input, size); } -static int pp_odn_edit_dpm_table (void *handle,uint32_t type,long *input,uint32_t size) +static int pp_odn_edit_dpm_table (void *handle,enum PP_OD_DPM_TABLE_COMMAND type, +long *input,uint32_t size) {struct pp_hwmgr *hwmgr = handle;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 17/73 wifi: ath11k: Fix qmi_msg_handler data structure initialization
In reply to Sasha LevinFrom: Rahul Bhattacharjee <[email protected]>
[ Upstream commit ed3725e15a154ebebf44e0c34806c57525483f92 ]
qmi_msg_handler is required to be null terminated by QMI module. There might be a case where a handler for a msg id is not present in the handlers array which can lead to infinite loop while searching the handler and therefore out of bound access in qmi_invoke_handler(). Hence update the initialization in qmi_msg_handler data structure.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.5.0.1-01100-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/qmi.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/ath/ath11k/qmi.c +3 -0
@@ -3083,6 +3083,9 @@ static const struct qmi_msg_handler ath11k_qmi_msg_handlers[] = { sizeof(struct qmi_wlfw_fw_init_done_ind_msg_v01), .fn = ath11k_qmi_msg_fw_init_done_cb, }, + +/* end of list */ + {}, }; static int ath11k_qmi_ops_new_server(struct qmi_handle *qmi_hdl,
Signature · 7 lines
2.35.1 -- ath11k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath11k
Sasha Levin
maintainerPATCH 28/73 s390/ctcm: Fix return type of ctc{mp,}m_tx()
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit aa5bf80c3c067b82b4362cd6e8e2194623bcaca6 ]
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/s390/net/ctcm_main.c:1064:21: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.ndo_start_xmit = ctcm_tx,
^~~~~~~
drivers/s390/net/ctcm_main.c:1072:21: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.ndo_start_xmit = ctcmpc_tx,
^~~~~~~~~
->ndo_start_xmit() in 'struct net_device_ops' expects a return type of 'netdev_tx_t', not 'int'. Adjust the return type of ctc{mp,}m_tx() to match the prototype's to resolve the warning and potential CFI failure, should s390 select ARCH_SUPPORTS_CFI_CLANG in the future.
Additionally, while in the area, remove a comment block that is no longer relevant.
--- drivers/s390/net/ctcm_main.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/s390/net/ctcm_main.c +2 -9
@@ -825,16 +825,9 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb)/* * Start transmission of a packet. * Called from generic network device layer. -* -* skb Pointer to buffer containing the packet. -* dev Pointer to interface struct. -* -* returns 0 if packet consumed, !0 if packet rejected. -* Note: If we return !0, then the packet is free'd by -* the generic network layer. */ /* first merge version - leaving both functions separated */ -static int ctcm_tx (struct sk_buff *skb,struct net_device *dev) +static netdev_tx_t ctcm_tx (struct sk_buff *skb,struct net_device *dev) {struct ctcm_priv *priv = dev->ml_priv;
@@ -877,7 +870,7 @@ static int ctcm_tx(struct sk_buff *skb, struct net_device *dev) }/* unmerged MPC variant of ctcm_tx */ -static int ctcmpc_tx (struct sk_buff *skb,struct net_device *dev) +static netdev_tx_t ctcmpc_tx (struct sk_buff *skb,struct net_device *dev) {int len =0 ;struct ctcm_priv *priv = dev->ml_priv;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 29/73 s390/netiucv: Fix return type of netiucv_tx()
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 88d86d18d7cf7e9137c95f9d212bb9fff8a1b4be ]
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/s390/net/netiucv.c:1854:21: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.ndo_start_xmit = netiucv_tx,
^~~~~~~~~~
->ndo_start_xmit() in 'struct net_device_ops' expects a return type of 'netdev_tx_t', not 'int'. Adjust the return type of netiucv_tx() to match the prototype's to resolve the warning and potential CFI failure, should s390 select ARCH_SUPPORTS_CFI_CLANG in the future.
Additionally, while in the area, remove a comment block that is no longer relevant.
--- drivers/s390/net/netiucv.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/s390/net/netiucv.c +1 -8
@@ -1248,15 +1248,8 @@ static int netiucv_close(struct net_device *dev)/* * Start transmission of a packet. * Called from generic network device layer. -* -* @param skb Pointer to buffer containing the packet. -* @param dev Pointer to interface struct. -* -* @return 0 if packet consumed, !0 if packet rejected. -* Note: If we return !0, then the packet is free'd by -* the generic network layer. */ -static int netiucv_tx (struct sk_buff *skb,struct net_device *dev) +static netdev_tx_t netiucv_tx (struct sk_buff *skb,struct net_device *dev) {struct netiucv_priv *privptr =netdev_priv (dev);int rc;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 30/73 s390/lcs: Fix return type of lcs_start_xmit()
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit bb16db8393658e0978c3f0d30ae069e878264fa3 ]
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/s390/net/lcs.c:2090:21: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.ndo_start_xmit = lcs_start_xmit,
^~~~~~~~~~~~~~
drivers/s390/net/lcs.c:2097:21: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.ndo_start_xmit = lcs_start_xmit,
^~~~~~~~~~~~~~
->ndo_start_xmit() in 'struct net_device_ops' expects a return type of 'netdev_tx_t', not 'int'. Adjust the return type of lcs_start_xmit() to match the prototype's to resolve the warning and potential CFI failure, should s390 select ARCH_SUPPORTS_CFI_CLANG in the future.
--- drivers/s390/net/lcs.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/s390/net/lcs.c +3 -5
@@ -1519,9 +1519,8 @@ lcs_txbuffer_cb(struct lcs_channel *channel, struct lcs_buffer *buffer)/* * Packet transmit function called by network stack */ -static int -__lcs_start_xmit (struct lcs_card *card,struct sk_buff *skb, -struct net_device *dev) +static netdev_tx_t __lcs_start_xmit (struct lcs_card *card,struct sk_buff *skb, +struct net_device *dev) {struct lcs_header *header;int rc =NETDEV_TX_OK ;
@@ -1582,8 +1581,7 @@ __lcs_start_xmit(struct lcs_card *card, struct sk_buff *skb,return rc; } -static int -lcs_start_xmit (struct sk_buff *skb,struct net_device *dev) +static netdev_tx_t lcs_start_xmit (struct sk_buff *skb,struct net_device *dev) {struct lcs_card *card;int rc;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 31/73 drm/amd/display: Disable DRR actions during state commit
In reply to Sasha LevinFrom: Wesley Chalmers <[email protected]>
[ Upstream commit de020e5fa9ebc6fc32e82ae6ccb0282451ed937c ]
[WHY]
Committing a state while performing DRR actions can cause underflow.
[HOW]
Disabled features performing DRR actions during state commit. Need to follow-up on why DRR actions affect state commit.
--- drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c | 3 --- 1 file changed, 3 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c +0 -3
@@ -973,8 +973,5 @@ void dcn30_prepare_bandwidth(struct dc *dc, dc->clk_mgr->funcs->set_max_memclk (dc->clk_mgr, dc->clk_mgr->bw_params->clk_table.entries[dc->clk_mgr->bw_params->clk_table.num_entries -1 ].memclk_mhz);dcn20_prepare_bandwidth (dc, context); - -dc_dmub_srv_p_state_delegate (dc, - context->bw_ctx.bw.dcn.clk.fw_based_mclk_switching, context); }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 35/73 drm/mediatek: Fix return type of mtk_hdmi_bridge_mode_valid()
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 890d637523eec9d730e3885532fa1228ba678880 ]
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/gpu/drm/mediatek/mtk_hdmi.c:1407:16: error: incompatible function pointer types initializing 'enum drm_mode_status (*)(struct drm_bridge *, const struct drm_display_info *, const struct drm_display_mode *)' with an expression of type 'int (struct drm_bridge *, const struct drm_display_info *, const struct drm_display_mode *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.mode_valid = mtk_hdmi_bridge_mode_valid,
^~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
->mode_valid() in 'struct drm_bridge_funcs' expects a return type of 'enum drm_mode_status', not 'int'. Adjust the return type of mtk_hdmi_bridge_mode_valid() to match the prototype's to resolve the warning and CFI failure.
--- drivers/gpu/drm/mediatek/mtk_hdmi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/mediatek/mtk_hdmi.c +4 -3
@@ -1203,9 +1203,10 @@ static enum drm_connector_status mtk_hdmi_detect(struct mtk_hdmi *hdmi)return mtk_hdmi_update_plugged_status (hdmi); } -static int mtk_hdmi_bridge_mode_valid (struct drm_bridge *bridge, -const struct drm_display_info *info, -const struct drm_display_mode *mode) +static enum drm_mode_status +mtk_hdmi_bridge_mode_valid (struct drm_bridge *bridge, +const struct drm_display_info *info, +const struct drm_display_mode *mode) {struct mtk_hdmi *hdmi =hdmi_ctx_from_bridge (bridge);struct drm_bridge *next_bridge;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 33/73 drm/rockchip: Use drm_mode_copy()
In reply to Sasha LevinFrom: Ville Syrjälä <[email protected]>
[ Upstream commit 2bfaa28000d2830d3209161a4541cce0660e1b84 ]
struct drm_display_mode embeds a list head, so overwriting the full struct with another one will corrupt the list (if the destination mode is on a list). Use drm_mode_copy() instead which explicitly preserves the list head of the destination mode.
Even if we know the destination mode is not on any list using drm_mode_copy() seems decent as it sets a good example. Bad examples of not using it might eventually get copied into code where preserving the list head actually matters.
Obviously one case not covered here is when the mode itself is embedded in a larger structure and the whole structure is copied. But if we are careful when copying into modes embedded in structures I think we can be a little more reassured that bogus list heads haven't been propagated in.
@is_mode_copy@
@@drm_mode_copy(...)
{
...
}
@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)
@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)
@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode
--- drivers/gpu/drm/rockchip/cdn-dp-core.c | 2 +- drivers/gpu/drm/rockchip/inno_hdmi.c | 2 +- drivers/gpu/drm/rockchip/rk3066_hdmi.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/rockchip/cdn-dp-core.c +1 -1
@@ -571,7 +571,7 @@ static void cdn_dp_encoder_mode_set(struct drm_encoder *encoder, video->v_sync_polarity = !!(mode->flags &DRM_MODE_FLAG_NVSYNC ); video->h_sync_polarity = !!(mode->flags &DRM_MODE_FLAG_NHSYNC ); -memcpy (&dp->mode, adjusted,sizeof (*mode)); +drm_mode_copy (&dp->mode, adjusted); }static bool cdn_dp_check_link_status (struct cdn_dp_device *dp)
drivers/gpu/drm/rockchip/inno_hdmi.c +1 -1
@@ -499,7 +499,7 @@ static void inno_hdmi_encoder_mode_set(struct drm_encoder *encoder,inno_hdmi_setup (hdmi, adj_mode);/* Store the display mode for plugin/DPMS poweron events */ -memcpy (&hdmi->previous_mode, adj_mode,sizeof (hdmi->previous_mode)); +drm_mode_copy (&hdmi->previous_mode, adj_mode); }static void inno_hdmi_encoder_enable (struct drm_encoder *encoder)
drivers/gpu/drm/rockchip/rk3066_hdmi.c +1 -1
@@ -395,7 +395,7 @@ rk3066_hdmi_encoder_mode_set(struct drm_encoder *encoder,struct rk3066_hdmi *hdmi =encoder_to_rk3066_hdmi (encoder);/* Store the display mode for plugin/DPMS poweron events. */ -memcpy (&hdmi->previous_mode, adj_mode,sizeof (hdmi->previous_mode)); +drm_mode_copy (&hdmi->previous_mode, adj_mode); }static void rk3066_hdmi_encoder_enable (struct drm_encoder *encoder)
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 32/73 drm/msm: Use drm_mode_copy()
In reply to Sasha LevinFrom: Ville Syrjälä <[email protected]>
[ Upstream commit b2a1c5ca50db22b3677676dd5bad5f6092429acf ]
struct drm_display_mode embeds a list head, so overwriting the full struct with another one will corrupt the list (if the destination mode is on a list). Use drm_mode_copy() instead which explicitly preserves the list head of the destination mode.
Even if we know the destination mode is not on any list using drm_mode_copy() seems decent as it sets a good example. Bad examples of not using it might eventually get copied into code where preserving the list head actually matters.
Obviously one case not covered here is when the mode itself is embedded in a larger structure and the whole structure is copied. But if we are careful when copying into modes embedded in structures I think we can be a little more reassured that bogus list heads haven't been propagated in.
@is_mode_copy@
@@drm_mode_copy(...)
{
...
}
@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)
@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)
@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode
--- drivers/gpu/drm/msm/dp/dp_display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/dp/dp_display.c +1 -1
@@ -857,7 +857,7 @@ static int dp_display_set_mode(struct msm_dp *dp_display, dp = container_of(dp_display, struct dp_display_private, dp_display); - dp->panel->dp_mode.drm_mode = mode->drm_mode; +drm_mode_copy (&dp->panel->dp_mode.drm_mode, &mode->drm_mode); dp->panel->dp_mode.bpp = mode->bpp; dp->panel->dp_mode.capabilities = mode->capabilities;dp_panel_init_panel_info (dp->panel);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 39/73 drm/amd/display: Workaround to increase phantom pipe vactive in pipesplit
In reply to Sasha LevinFrom: George Shen <[email protected]>
[ Upstream commit 5b8f9deaf3b6badfc0da968e6e07ceabd19700b6 ]
[Why]
Certain high resolution displays exhibit DCC line corruption with SubVP enabled. This is likely due to insufficient DCC meta data buffered immediately after the mclk switch.
[How]
Add workaround to increase phantom pipe vactive height by meta_row_height number of lines, thus increasing the amount of meta data buffered immediately after mclk switch finishes.
--- drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c +7 -0
@@ -485,9 +485,11 @@ void dcn32_set_phantom_stream_timing(struct dc *dc,unsigned int i, pipe_idx;struct pipe_ctx *pipe;uint32_t phantom_vactive, phantom_bp, pstate_width_fw_delay_lines; +unsigned int num_dpp;unsigned int vlevel = context->bw_ctx.dml.vba.VoltageLevel;unsigned int dcfclk = context->bw_ctx.dml.vba.DCFCLKState[vlevel][context->bw_ctx.dml.vba.maxMpcComb];unsigned int socclk = context->bw_ctx.dml.vba.SOCCLKPerState[vlevel]; +struct vba_vars_st *vba = &context->bw_ctx.dml.vba;dc_assert_fp_enabled ();
@@ -523,6 +525,11 @@ void dcn32_set_phantom_stream_timing(struct dc *dc, phantom_vactive =get_subviewport_lines_needed_in_mall (&context->bw_ctx.dml, pipes, pipe_cnt, pipe_idx) + pstate_width_fw_delay_lines + dc->caps.subvp_swath_height_margin_lines; +// W/A for DCC corruption with certain high resolution timings. +// Determing if pipesplit is used. If so, add meta_row_height to the phantom vactive. + num_dpp = vba->NoOfDPP[vba->VoltageLevel][vba->maxMpcComb][vba->pipe_plane[pipe_idx]]; + phantom_vactive += num_dpp >1 ? vba->meta_row_height[vba->pipe_plane[pipe_idx]] :0 ; +// For backporch of phantom pipe, use vstartup of the main pipe phantom_bp =get_vstartup (&context->bw_ctx.dml, pipes, pipe_cnt, pipe_idx);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 34/73 drm/sti: Use drm_mode_copy()
In reply to Sasha LevinFrom: Ville Syrjälä <[email protected]>
[ Upstream commit 442cf8e22ba25a77cb9092d78733fdbac9844e50 ]
struct drm_display_mode embeds a list head, so overwriting the full struct with another one will corrupt the list (if the destination mode is on a list). Use drm_mode_copy() instead which explicitly preserves the list head of the destination mode.
Even if we know the destination mode is not on any list using drm_mode_copy() seems decent as it sets a good example. Bad examples of not using it might eventually get copied into code where preserving the list head actually matters.
Obviously one case not covered here is when the mode itself is embedded in a larger structure and the whole structure is copied. But if we are careful when copying into modes embedded in structures I think we can be a little more reassured that bogus list heads haven't been propagated in.
@is_mode_copy@
@@drm_mode_copy(...)
{
...
}
@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)
@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)
@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode
--- drivers/gpu/drm/sti/sti_dvo.c | 2 +- drivers/gpu/drm/sti/sti_hda.c | 2 +- drivers/gpu/drm/sti/sti_hdmi.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/sti/sti_dvo.c +1 -1
@@ -288,7 +288,7 @@ static void sti_dvo_set_mode(struct drm_bridge *bridge,DRM_DEBUG_DRIVER ("\n" ); -memcpy (&dvo->mode, mode,sizeof (struct drm_display_mode )); +drm_mode_copy (&dvo->mode, mode);/* According to the path used (main or aux), the dvo clocks should * have a different parent clock. */
drivers/gpu/drm/sti/sti_hda.c +1 -1
@@ -524,7 +524,7 @@ static void sti_hda_set_mode(struct drm_bridge *bridge,DRM_DEBUG_DRIVER ("\n" ); -memcpy (&hda->mode, mode,sizeof (struct drm_display_mode )); +drm_mode_copy (&hda->mode, mode);if (!hda_get_mode_idx (hda->mode, &mode_idx)) {DRM_ERROR ("Undefined mode\n" );
drivers/gpu/drm/sti/sti_hdmi.c +1 -1
@@ -941,7 +941,7 @@ static void sti_hdmi_set_mode(struct drm_bridge *bridge,DRM_DEBUG_DRIVER ("\n" );/* Copy the drm display mode in the connector local structure */ -memcpy (&hdmi->mode, mode,sizeof (struct drm_display_mode )); +drm_mode_copy (&hdmi->mode, mode);/* Update clock framerate according to the selected mode */ ret =clk_set_rate (hdmi->clk_pix, mode->clock *1000 );
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 40/73 drm/amd/display: fix array index out of bound error in bios parser
In reply to Sasha LevinFrom: Aurabindo Pillai <[email protected]>
[ Upstream commit 4fc1ba4aa589ca267468ad23fedef37562227d32 ]
[Why&How]
Firmware headers dictate that gpio_pin array only has a size of 8. The count returned from vbios however is greater than 8.
Fix this by not using array indexing but incrementing the pointer since gpio_pin definition in atomfirmware.h is hardcoded to size 8
--- .../gpu/drm/amd/display/dc/bios/bios_parser2.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c +7 -9
@@ -487,6 +487,7 @@ static enum bp_result get_gpio_i2c_info(uint32_t count =0 ;unsigned int table_index =0 ;bool find_valid = false; +struct atom_gpio_pin_assignment *pin;if (!info)return BP_RESULT_BADINPUT ;
@@ -514,20 +515,17 @@ static enum bp_result get_gpio_i2c_info( - sizeof(struct atom_common_table_header)) /sizeof (struct atom_gpio_pin_assignment ); + pin = (struct atom_gpio_pin_assignment *) header->gpio_pin; +for (table_index =0 ; table_index < count; table_index++) { -if (((record->i2c_id &I2C_HW_CAP ) == ( - header->gpio_pin[table_index].gpio_id & -I2C_HW_CAP )) && - ((record->i2c_id &I2C_HW_ENGINE_ID_MASK ) == - (header->gpio_pin[table_index].gpio_id & -I2C_HW_ENGINE_ID_MASK )) && - ((record->i2c_id &I2C_HW_LANE_MUX ) == - (header->gpio_pin[table_index].gpio_id & -I2C_HW_LANE_MUX ))) { +if (((record->i2c_id &I2C_HW_CAP ) == (pin->gpio_id &I2C_HW_CAP )) && + ((record->i2c_id &I2C_HW_ENGINE_ID_MASK ) == (pin->gpio_id &I2C_HW_ENGINE_ID_MASK )) && + ((record->i2c_id &I2C_HW_LANE_MUX ) == (pin->gpio_id &I2C_HW_LANE_MUX ))) {/* still valid */ find_valid = true;break ; } + pin = (struct atom_gpio_pin_assignment *)((uint8_t *)pin +sizeof (struct atom_gpio_pin_assignment )); }/* If we don't find the entry that we are looking for then
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 41/73 nvme-auth: don't override ctrl keys before validation
In reply to Sasha LevinFrom: Sagi Grimberg <[email protected]>
[ Upstream commit 01604350e14560d4d69323eb1ba12a257a643ea8 ]
Replace ctrl ctrl_key/host_key only after nvme_auth_generate_key is successful. Also, this fixes a bug where the keys are leaked.
--- drivers/nvme/host/core.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/nvme/host/core.c +10 -2
@@ -3739,13 +3739,17 @@ static ssize_t nvme_ctrl_dhchap_secret_store(struct device *dev,memcpy (dhchap_secret, buf, count);nvme_auth_stop (ctrl);if (strcmp (dhchap_secret, opts->dhchap_secret)) { +struct nvme_dhchap_key *key, *host_key;int ret; - ret =nvme_auth_generate_key (dhchap_secret, &ctrl->host_key); + ret =nvme_auth_generate_key (dhchap_secret, &key);if (ret)return ret;kfree (opts->dhchap_secret); opts->dhchap_secret = dhchap_secret; + host_key = ctrl->host_key; + ctrl->host_key = key; +nvme_auth_free_key (host_key);/* Key has changed; re-authentication with new key */ nvme_auth_reset (ctrl); }
@@ -3789,13 +3793,17 @@ static ssize_t nvme_ctrl_dhchap_ctrl_secret_store(struct device *dev,memcpy (dhchap_secret, buf, count);nvme_auth_stop (ctrl);if (strcmp (dhchap_secret, opts->dhchap_ctrl_secret)) { +struct nvme_dhchap_key *key, *ctrl_key;int ret; - ret =nvme_auth_generate_key (dhchap_secret, &ctrl->ctrl_key); + ret =nvme_auth_generate_key (dhchap_secret, &key);if (ret)return ret;kfree (opts->dhchap_ctrl_secret); opts->dhchap_ctrl_secret = dhchap_secret; + ctrl_key = ctrl->ctrl_key; + ctrl->ctrl_key = key; +nvme_auth_free_key (ctrl_key);/* Key has changed; re-authentication with new key */ nvme_auth_reset (ctrl); }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 55/73 drm/amd/display: Use the largest vready_offset in pipe group
In reply to Sasha LevinFrom: Wesley Chalmers <[email protected]>
[ Upstream commit 5842abd985b792a3b13a89b6dae4869b56656c92 ]
[WHY]
Corruption can occur in LB if vready_offset is not large enough. DML calculates vready_offset for each pipe, but we currently select the top pipe's vready_offset, which is not necessarily enough for all pipes in the group.
[HOW]
Wherever program_global_sync is currently called, iterate through the entire pipe group and find the highest vready_offset.
--- .../amd/display/dc/dcn10/dcn10_hw_sequencer.c | 30 +++++++++++++++++-- .../drm/amd/display/dc/dcn20/dcn20_hwseq.c | 29 ++++++++++++++++-- 2 files changed, 55 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +28 -2
@@ -867,6 +867,32 @@ static void false_optc_underflow_wa( tg->funcs->clear_optc_underflow (tg); } +static int calculate_vready_offset_for_group (struct pipe_ctx *pipe) +{ +struct pipe_ctx *other_pipe; +int vready_offset = pipe->pipe_dlg_param.vready_offset; + +/* Always use the largest vready_offset of all connected pipes */ +for (other_pipe = pipe->bottom_pipe; other_pipe !=NULL ; other_pipe = other_pipe->bottom_pipe) { +if (other_pipe->pipe_dlg_param.vready_offset > vready_offset) + vready_offset = other_pipe->pipe_dlg_param.vready_offset; + } +for (other_pipe = pipe->top_pipe; other_pipe !=NULL ; other_pipe = other_pipe->top_pipe) { +if (other_pipe->pipe_dlg_param.vready_offset > vready_offset) + vready_offset = other_pipe->pipe_dlg_param.vready_offset; + } +for (other_pipe = pipe->next_odm_pipe; other_pipe !=NULL ; other_pipe = other_pipe->next_odm_pipe) { +if (other_pipe->pipe_dlg_param.vready_offset > vready_offset) + vready_offset = other_pipe->pipe_dlg_param.vready_offset; + } +for (other_pipe = pipe->prev_odm_pipe; other_pipe !=NULL ; other_pipe = other_pipe->prev_odm_pipe) { +if (other_pipe->pipe_dlg_param.vready_offset > vready_offset) + vready_offset = other_pipe->pipe_dlg_param.vready_offset; + } + +return vready_offset; +} + enum dc_status dcn10_enable_stream_timing( struct pipe_ctx *pipe_ctx, struct dc_state *context,
@@ -902,7 +928,7 @@ enum dc_status dcn10_enable_stream_timing( pipe_ctx->stream_res.tg->funcs->program_timing( pipe_ctx->stream_res.tg, &stream->timing, - pipe_ctx->pipe_dlg_param.vready_offset, + calculate_vready_offset_for_group(pipe_ctx), pipe_ctx->pipe_dlg_param.vstartup_start, pipe_ctx->pipe_dlg_param.vupdate_offset, pipe_ctx->pipe_dlg_param.vupdate_width,
@@ -2869,7 +2895,7 @@ void dcn10_program_pipe( pipe_ctx->stream_res.tg->funcs->program_global_sync ( pipe_ctx->stream_res.tg, - pipe_ctx->pipe_dlg_param.vready_offset, +calculate_vready_offset_for_group (pipe_ctx), pipe_ctx->pipe_dlg_param.vstartup_start, pipe_ctx->pipe_dlg_param.vupdate_offset, pipe_ctx->pipe_dlg_param.vupdate_width);
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c +27 -2
@@ -1608,6 +1608,31 @@ static void dcn20_update_dchubp_dpp( hubp->funcs->phantom_hubp_post_enable (hubp); } +static int calculate_vready_offset_for_group (struct pipe_ctx *pipe) +{ +struct pipe_ctx *other_pipe; +int vready_offset = pipe->pipe_dlg_param.vready_offset; + +/* Always use the largest vready_offset of all connected pipes */ +for (other_pipe = pipe->bottom_pipe; other_pipe !=NULL ; other_pipe = other_pipe->bottom_pipe) { +if (other_pipe->pipe_dlg_param.vready_offset > vready_offset) + vready_offset = other_pipe->pipe_dlg_param.vready_offset; + } +for (other_pipe = pipe->top_pipe; other_pipe !=NULL ; other_pipe = other_pipe->top_pipe) { +if (other_pipe->pipe_dlg_param.vready_offset > vready_offset) + vready_offset = other_pipe->pipe_dlg_param.vready_offset; + } +for (other_pipe = pipe->next_odm_pipe; other_pipe !=NULL ; other_pipe = other_pipe->next_odm_pipe) { +if (other_pipe->pipe_dlg_param.vready_offset > vready_offset) + vready_offset = other_pipe->pipe_dlg_param.vready_offset; + } +for (other_pipe = pipe->prev_odm_pipe; other_pipe !=NULL ; other_pipe = other_pipe->prev_odm_pipe) { +if (other_pipe->pipe_dlg_param.vready_offset > vready_offset) + vready_offset = other_pipe->pipe_dlg_param.vready_offset; + } + +return vready_offset; +} static void dcn20_program_pipe( struct dc *dc,
@@ -1626,7 +1651,7 @@ static void dcn20_program_pipe( && !pipe_ctx->prev_odm_pipe) { pipe_ctx->stream_res.tg->funcs->program_global_sync ( pipe_ctx->stream_res.tg, - pipe_ctx->pipe_dlg_param.vready_offset, +calculate_vready_offset_for_group (pipe_ctx), pipe_ctx->pipe_dlg_param.vstartup_start, pipe_ctx->pipe_dlg_param.vupdate_offset, pipe_ctx->pipe_dlg_param.vupdate_width);
@@ -2040,7 +2065,7 @@ bool dcn20_update_bandwidth( pipe_ctx->stream_res.tg->funcs->program_global_sync ( pipe_ctx->stream_res.tg, - pipe_ctx->pipe_dlg_param.vready_offset, +calculate_vready_offset_for_group (pipe_ctx), pipe_ctx->pipe_dlg_param.vstartup_start, pipe_ctx->pipe_dlg_param.vupdate_offset, pipe_ctx->pipe_dlg_param.vupdate_width);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 56/73 drm/amd/display: Fix DTBCLK disable requests and SRC_SEL programming
In reply to Sasha LevinFrom: Alvin Lee <[email protected]>
[ Upstream commit f6015da7f2410109bd2ccd2e2828f26185aeb81d ]
[Description]
- When transitioning FRL / DP2 is not required, we will always request DTBCLK = 0Mhz, but PMFW returns the min freq
- This causes us to make DTBCLK requests every time we call optimize after transitioning from FRL to non-FRL
- If DTBCLK is not required, request the min instead (then we only need to make 1 extra request at boot time)
- Also when programming PIPE_DTO_SRC_SEL, don't programming for DP first, just programming once for the required selection (programming DP on an HDMI connection then switching back causes corruption)
--- .../gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c | 2 +- drivers/gpu/drm/amd/display/dc/dcn32/dcn32_dccg.c | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c +1 -1
@@ -436,7 +436,7 @@ static void dcn32_update_clocks(struct clk_mgr *clk_mgr_base, }if (!new_clocks->dtbclk_en) { - new_clocks->ref_dtbclk_khz =0 ; + new_clocks->ref_dtbclk_khz = clk_mgr_base->bw_params->clk_table.entries[0 ].dtbclk_mhz *1000 ; }/* clock limits are received with MHz precision, divide by 1000 to prevent setting clocks at every call */
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_dccg.c +1 -5
@@ -225,11 +225,7 @@ void dccg32_set_dtbclk_dto( }else {REG_UPDATE_2 (OTG_PIXEL_RATE_CNTL [params->otg_inst],DTBCLK_DTO_ENABLE [params->otg_inst],0 , -PIPE_DTO_SRC_SEL [params->otg_inst],1 ); -if (params->is_hdmi) -REG_UPDATE (OTG_PIXEL_RATE_CNTL [params->otg_inst], -PIPE_DTO_SRC_SEL [params->otg_inst],0 ); - +PIPE_DTO_SRC_SEL [params->otg_inst], params->is_hdmi ?0 :1 );REG_WRITE (DTBCLK_DTO_MODULO [params->otg_inst],0 );REG_WRITE (DTBCLK_DTO_PHASE [params->otg_inst],0 ); }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 57/73 ASoC: amd: yc: Add Xiaomi Redmi Book Pro 14 2022 into DMI table
In reply to Sasha LevinFrom: Artem Lukyanov <[email protected]>
[ Upstream commit c1dd6bf6199752890d8c59d895dd45094da51d1f ]
This model requires an additional detection quirk to enable the internal microphone - BIOS doesn't seem to support AcpDmicConnected (nothing in acpidump output).
--- sound/soc/amd/yc/acp6x-mach.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/amd/yc/acp6x-mach.c +7 -0
@@ -213,6 +213,13 @@ static const struct dmi_system_id yc_acp_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m17 R5 AMD"), } }, + { + .driver_data = &acp6x_card, + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "TIMI"), + DMI_MATCH(DMI_PRODUCT_NAME, "Redmi Book Pro 14 2022"), + } + }, {} };
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 45/73 net: ethernet: mtk_eth_soc: drop packets to WDMA if the ring is full
In reply to Sasha LevinFrom: Felix Fietkau <[email protected]>
[ Upstream commit f4b2fa2c25e1ade78f766aa82e733a0b5198d484 ]
Improves handling of DMA ring overflow.
Clarify other WDMA drop related comment.
--- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 5 ++++- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +4 -1
@@ -3311,9 +3311,12 @@ static int mtk_hw_init(struct mtk_eth *eth)mtk_w32 (eth,0x21021000 ,MTK_FE_INT_GRP );if (MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V2 )) { -/* PSE should not drop port8 and port9 packets */ +/* PSE should not drop port8 and port9 packets from WDMA Tx */ mtk_w32 (eth,0x00000300 ,PSE_DROP_CFG ); +/* PSE should drop packets to port 8/9 on WDMA Rx ring full */ +mtk_w32 (eth,0x00000300 ,PSE_PPE0_DROP ); +/* PSE Free Queue Flow Control */ mtk_w32 (eth,0x01fa01f4 ,PSE_FQFC_CFG2 );
drivers/net/ethernet/mediatek/mtk_eth_soc.h +1 -0
@@ -121,6 +121,7 @@#define PSE_FQFC_CFG1 0x100#define PSE_FQFC_CFG2 0x104#define PSE_DROP_CFG 0x108 +#define PSE_PPE0_DROP 0x110/* PSE Input Queue Reservation Register*/ #define PSE_IQ_REV (x) (0x140 + (((x) - 1) << 2))
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 53/73 media: mediatek: vcodec: Can't set dst buffer to done when lat decode error
In reply to Sasha LevinFrom: Yunfei Dong <[email protected]>
[ Upstream commit 3568ecd3f3a6d133ab7feffbba34955c8c79bbc4 ]
Core thread will call v4l2_m2m_buf_done to set dst buffer done for lat architecture. If lat call v4l2_m2m_buf_done_and_job_finish to free dst buffer when lat decode error, core thread will access kernel NULL pointer dereference, then crash.
--- .../media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c +1 -1
@@ -250,7 +250,7 @@ static void mtk_vdec_worker(struct work_struct *work) state = ret ?VB2_BUF_STATE_ERROR :VB2_BUF_STATE_DONE ;if (!IS_VDEC_LAT_ARCH (dev->vdec_pdata->hw_arch) || - ctx->current_codec ==V4L2_PIX_FMT_VP8_FRAME || ret) { + ctx->current_codec ==V4L2_PIX_FMT_VP8_FRAME ) {v4l2_m2m_buf_done_and_job_finish (dev->m2m_dev_dec, ctx->m2m_ctx, state);if (src_buf_req)v4l2_ctrl_request_complete (src_buf_req, &ctx->ctrl_hdl);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 61/73 wifi: mt76: do not run mt76u_status_worker if the device is not running
In reply to Sasha LevinFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit bd5dac7ced5a7c9faa4dc468ac9560c3256df845 ]
Fix the following NULL pointer dereference avoiding to run mt76u_status_worker thread if the device is not running yet.
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] CPU: 0 PID: 98 Comm: kworker/u2:2 Not tainted 5.14.0+ #78 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014 Workqueue: mt76 mt76u_tx_status_data RIP: 0010:mt76x02_mac_fill_tx_status.isra.0+0x82c/0x9e0 Code: c5 48 b8 00 00 00 00 00 fc ff df 80 3c 02 00 0f 85 94 01 00 00 48 b8 00 00 00 00 00 fc ff df 4d 8b 34 24 4c 89 f2 48 c1 ea 03 <0f> b6 04 02 84 c0 74 08 3c 03 0f 8e 89 01 00 00 41 8b 16 41 0f b7 RSP: 0018:ffffc900005af988 EFLAGS: 00010246 RAX: dffffc0000000000 RBX: ffffc900005afae8 RCX: 0000000000000000 RDX: 0000000000000000 RSI: ffffffff832fc661 RDI: ffffc900005afc2a RBP: ffffc900005afae0 R08: 0000000000000001 R09: fffff520000b5f3c R10: 0000000000000003 R11: fffff520000b5f3b R12: ffff88810b6132d8 R13: 000000000000ffff R14: 0000000000000000 R15: ffffc900005afc28 FS: 0000000000000000(0000) GS:ffff88811aa00000(0000)
knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fa0eda6a000 CR3: 0000000118f17000 CR4: 0000000000750ef0
PKRU: 55555554
Call Trace: mt76x02_send_tx_status+0x1d2/0xeb0 mt76x02_tx_status_data+0x8e/0xd0 mt76u_tx_status_data+0xe1/0x240 process_one_work+0x92b/0x1460 worker_thread+0x95/0xe00 kthread+0x3a1/0x480 ret_from_fork+0x1f/0x30 Modules linked in: --[ end trace 8df5d20fc5040f65 ]-- RIP: 0010:mt76x02_mac_fill_tx_status.isra.0+0x82c/0x9e0 Code: c5 48 b8 00 00 00 00 00 fc ff df 80 3c 02 00 0f 85 94 01 00 00 48 b8 00 00 00 00 00 fc ff df 4d 8b 34 24 4c 89 f2 48 c1 ea 03 <0f> b6 04 02 84 c0 74 08 3c 03 0f 8e 89 01 00 00 41 8b 16 41 0f b7 RSP: 0018:ffffc900005af988 EFLAGS: 00010246 RAX: dffffc0000000000 RBX: ffffc900005afae8 RCX: 0000000000000000 RDX: 0000000000000000 RSI: ffffffff832fc661 RDI: ffffc900005afc2a RBP: ffffc900005afae0 R08: 0000000000000001 R09: fffff520000b5f3c R10: 0000000000000003 R11: fffff520000b5f3b R12: ffff88810b6132d8 R13: 000000000000ffff R14: 0000000000000000 R15: ffffc900005afc28 FS: 0000000000000000(0000) GS:ffff88811aa00000(0000)
knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fa0eda6a000 CR3: 0000000118f17000 CR4: 0000000000750ef0
PKRU: 55555554
Moreover move stat_work schedule out of the for loop.
--- drivers/net/wireless/mediatek/mt76/usb.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/net/wireless/mediatek/mt76/usb.c +7 -4
@@ -761,6 +761,9 @@ static void mt76u_status_worker(struct mt76_worker *w)struct mt76_queue *q;int i; +if (!test_bit (MT76_STATE_RUNNING , &dev->phy.state)) +return ; +for (i =0 ; i <IEEE80211_NUM_ACS ; i++) { q = dev->phy.q_tx[i];if (!q)
@@ -780,11 +783,11 @@ static void mt76u_status_worker(struct mt76_worker *w)wake_up (&dev->tx_wait);mt76_worker_schedule (&dev->tx_worker); - -if (dev->drv->tx_status_data && - !test_and_set_bit (MT76_READING_STATS , &dev->phy.state)) -queue_work (dev->wq, &dev->usb.stat_work); } + +if (dev->drv->tx_status_data && + !test_and_set_bit (MT76_READING_STATS , &dev->phy.state)) +queue_work (dev->wq, &dev->usb.stat_work); }static void mt76u_tx_status_data (struct work_struct *work)
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 70/73 regulator: core: Use different devices for resource allocation and DT lookup
In reply to Sasha LevinFrom: ChiYuan Huang <[email protected]>
[ Upstream commit 8f3cbcd6b440032ebc7f7d48a1689dcc70a4eb98 ]
Following by the below discussion, there's the potential UAF issue between regulator and mfd.
https://lore.kernel.org/all/[email protected]/
From the analysis of Yingliang
CPU A |CPU Bmt6370_probe() |
devm_mfd_add_devices() |
|mt6370_regulator_probe()
| regulator_register()
| //allocate init_data and add it to devres
| regulator_of_get_init_data()
i2c_unregister_device() |
device_del() |
devres_release_all() |
// init_data is freed |
release_nodes() |
| // using init_data causes UAF
| regulator_register()It's common to use mfd core to create child device for the regulator. In order to do the DT lookup for init data, the child that registered the regulator would pass its parent as the parameter. And this causes init data resource allocated to its parent, not itself. The issue happen when parent device is going to release and regulator core is still doing some operation of init data constraint for the regulator of child device.
To fix it, this patch expand 'regulator_register' API to use the different devices for init data allocation and DT lookup.
--- drivers/platform/x86/intel/int3472/clk_and_regulator.c | 3 ++- drivers/regulator/core.c | 8 ++++---- drivers/regulator/devres.c | 2 +- drivers/regulator/of_regulator.c | 2 +- drivers/regulator/stm32-vrefbuf.c | 2 +- include/linux/regulator/driver.h | 3 ++- 6 files changed, 11 insertions(+), 9 deletions(-)
drivers/platform/x86/intel/int3472/clk_and_regulator.c +2 -1
@@ -185,7 +185,8 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, cfg.init_data = &init_data; cfg.ena_gpiod = int3472->regulator.gpio; - int3472->regulator.rdev =regulator_register (&int3472->regulator.rdesc, + int3472->regulator.rdev =regulator_register (int3472->dev, + &int3472->regulator.rdesc, &cfg);if (IS_ERR (int3472->regulator.rdev)) { ret =PTR_ERR (int3472->regulator.rdev);
drivers/regulator/core.c +4 -4
@@ -5386,6 +5386,7 @@ static struct regulator_coupler generic_regulator_coupler = {/** * regulator_register - register regulator +* @dev: the device that drive the regulator * @regulator_desc: regulator to register * @cfg: runtime configuration for regulator *
@@ -5394,7 +5395,8 @@ static struct regulator_coupler generic_regulator_coupler = {* or an ERR_PTR() on error. */ struct regulator_dev * -regulator_register (const struct regulator_desc *regulator_desc, +regulator_register (struct device *dev, +const struct regulator_desc *regulator_desc,const struct regulator_config *cfg) {const struct regulator_init_data *init_data;
@@ -5403,7 +5405,6 @@ regulator_register(const struct regulator_desc *regulator_desc,struct regulator_dev *rdev;bool dangling_cfg_gpiod = false;bool dangling_of_gpiod = false; -struct device *dev;int ret, i;if (cfg ==NULL )
@@ -5415,8 +5416,7 @@ regulator_register(const struct regulator_desc *regulator_desc, goto rinse; } - dev = cfg->dev; -WARN_ON (!dev); +WARN_ON (!dev || !cfg->dev);if (regulator_desc->name ==NULL || regulator_desc->ops ==NULL ) { ret = -EINVAL ;
drivers/regulator/devres.c +1 -1
@@ -221,7 +221,7 @@ struct regulator_dev *devm_regulator_register(struct device *dev,if (!ptr)return ERR_PTR (-ENOMEM ); - rdev =regulator_register (regulator_desc, config); + rdev =regulator_register (dev, regulator_desc, config);if (!IS_ERR (rdev)) { *ptr = rdev;devres_add (dev, ptr);
drivers/regulator/of_regulator.c +1 -1
@@ -505,7 +505,7 @@ struct regulator_init_data *regulator_of_get_init_data(struct device *dev,struct device_node *child;struct regulator_init_data *init_data =NULL ; - child =regulator_of_get_init_node (dev, desc); + child =regulator_of_get_init_node (config->dev, desc);if (!child)return NULL ;
drivers/regulator/stm32-vrefbuf.c +1 -1
@@ -210,7 +210,7 @@ static int stm32_vrefbuf_probe(struct platform_device *pdev) pdev->dev.of_node, &stm32_vrefbuf_regu); - rdev =regulator_register (&stm32_vrefbuf_regu, &config); + rdev =regulator_register (&pdev->dev, &stm32_vrefbuf_regu, &config);if (IS_ERR (rdev)) { ret =PTR_ERR (rdev);dev_err (&pdev->dev,"register failed with error %d\n" , ret);
include/linux/regulator/driver.h +2 -1
@@ -687,7 +687,8 @@ static inline int regulator_err2notif(int err)struct regulator_dev * -regulator_register (const struct regulator_desc *regulator_desc, +regulator_register (struct device *dev, +const struct regulator_desc *regulator_desc,const struct regulator_config *config);struct regulator_dev * devm_regulator_register(struct device *dev,
Signature · 7 lines
2.35.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 5/73 wifi: ar5523: Fix use-after-free on ar5523_cmd() timed out
In reply to Sasha LevinFrom: Shigeru Yoshida <[email protected]>
[ Upstream commit b6702a942a069c2a975478d719e98d83cdae1797 ]
syzkaller reported use-after-free with the stack trace like below [1]:
[ 38.960489][ C3] ================================================================== [ 38.963216][ C3] BUG: KASAN: use-after-free in ar5523_cmd_tx_cb+0x220/0x240 [ 38.964950][ C3] Read of size 8 at addr ffff888048e03450 by task swapper/3/0 [ 38.966363][ C3] [ 38.967053][ C3] CPU: 3 PID: 0 Comm: swapper/3 Not tainted 6.0.0-09039-ga6afa4199d3d-dirty #18 [ 38.968464][ C3] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.0-1.fc36 04/01/2014 [ 38.969959][ C3] Call Trace: [ 38.970841][ C3] <IRQ> [ 38.971663][ C3] dump_stack_lvl+0xfc/0x174 [ 38.972620][ C3] print_report.cold+0x2c3/0x752 [ 38.973626][ C3] ? ar5523_cmd_tx_cb+0x220/0x240 [ 38.974644][ C3] kasan_report+0xb1/0x1d0 [ 38.975720][ C3] ? ar5523_cmd_tx_cb+0x220/0x240 [ 38.976831][ C3] ar5523_cmd_tx_cb+0x220/0x240 [ 38.978412][ C3] __usb_hcd_giveback_urb+0x353/0x5b0 [ 38.979755][ C3] usb_hcd_giveback_urb+0x385/0x430 [ 38.981266][ C3] dummy_timer+0x140c/0x34e0 [ 38.982925][ C3] ? notifier_call_chain+0xb5/0x1e0 [ 38.984761][ C3] ? rcu_read_lock_sched_held+0xb/0x60 [ 38.986242][ C3] ? lock_release+0x51c/0x790 [ 38.987323][ C3] ? _raw_read_unlock_irqrestore+0x37/0x70 [ 38.988483][ C3] ? __wake_up_common_lock+0xde/0x130 [ 38.989621][ C3] ? reacquire_held_locks+0x4a0/0x4a0 [ 38.990777][ C3] ? lock_acquire+0x472/0x550 [ 38.991919][ C3] ? rcu_read_lock_sched_held+0xb/0x60 [ 38.993138][ C3] ? lock_acquire+0x472/0x550 [ 38.994890][ C3] ? dummy_urb_enqueue+0x860/0x860 [ 38.996266][ C3] ? do_raw_spin_unlock+0x16f/0x230 [ 38.997670][ C3] ? dummy_urb_enqueue+0x860/0x860 [ 38.999116][ C3] call_timer_fn+0x1a0/0x6a0 [ 39.000668][ C3] ? add_timer_on+0x4a0/0x4a0 [ 39.002137][ C3] ? reacquire_held_locks+0x4a0/0x4a0 [ 39.003809][ C3] ? __next_timer_interrupt+0x226/0x2a0 [ 39.005509][ C3] __run_timers.part.0+0x69a/0xac0 [ 39.007025][ C3] ? dummy_urb_enqueue+0x860/0x860 [ 39.008716][ C3] ? call_timer_fn+0x6a0/0x6a0 [ 39.010254][ C3] ? cpuacct_percpu_seq_show+0x10/0x10 [ 39.011795][ C3] ? kvm_sched_clock_read+0x14/0x40 [ 39.013277][ C3] ? sched_clock_cpu+0x69/0x2b0 [ 39.014724][ C3] run_timer_softirq+0xb6/0x1d0 [ 39.016196][ C3] __do_softirq+0x1d2/0x9be [ 39.017616][ C3] __irq_exit_rcu+0xeb/0x190 [ 39.019004][ C3] irq_exit_rcu+0x5/0x20 [ 39.020361][ C3] sysvec_apic_timer_interrupt+0x8f/0xb0 [ 39.021965][ C3] </IRQ> [ 39.023237][ C3] <TASK>
In ar5523_probe(), ar5523_host_available() calls ar5523_cmd() as below (there are other functions which finally call ar5523_cmd()):
ar5523_probe()
-> ar5523_host_available()
-> ar5523_cmd_read()
-> ar5523_cmd()
If ar5523_cmd() timed out, then ar5523_host_available() failed and ar5523_probe() freed the device structure. So, ar5523_cmd_tx_cb() might touch the freed structure.
This patch fixes this issue by canceling in-flight tx cmd if submitted urb timed out.
--- drivers/net/wireless/ath/ar5523/ar5523.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/wireless/ath/ar5523/ar5523.c +6 -0
@@ -241,6 +241,11 @@ static void ar5523_cmd_tx_cb(struct urb *urb) } } +static void ar5523_cancel_tx_cmd (struct ar5523 *ar) +{ +usb_kill_urb (ar->tx_cmd.urb_tx); +} +static int ar5523_cmd (struct ar5523 *ar,u32 code,const void *idata,int ilen,void *odata,int olen,int flags) {
@@ -280,6 +285,7 @@ static int ar5523_cmd(struct ar5523 *ar, u32 code, const void *idata, }if (!wait_for_completion_timeout (&cmd->done,2 *HZ )) { +ar5523_cancel_tx_cmd (ar); cmd->odata =NULL ;ar5523_err (ar,"timeout waiting for command %02x reply\n" , code);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 4/73 wifi: ath9k: verify the expected usb_endpoints are present
In reply to Sasha LevinFrom: Fedor Pchelkin <[email protected]>
[ Upstream commit 16ef02bad239f11f322df8425d302be62f0443ce ]
The bug arises when a USB device claims to be an ATH9K but doesn't have the expected endpoints. (In this case there was an interrupt endpoint where the driver expected a bulk endpoint.) The kernel needs to be able to handle such devices without getting an internal error.
usb 1-1: BOGUS urb xfer, pipe 3 != type 1
WARNING: CPU: 3 PID: 500 at drivers/usb/core/urb.c:493 usb_submit_urb+0xce2/0x1430 drivers/usb/core/urb.c:493 Modules linked in: CPU: 3 PID: 500 Comm: kworker/3:2 Not tainted 5.10.135-syzkaller #0 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014 Workqueue: events request_firmware_work_func RIP: 0010:usb_submit_urb+0xce2/0x1430 drivers/usb/core/urb.c:493 Call Trace: ath9k_hif_usb_alloc_rx_urbs drivers/net/wireless/ath/ath9k/hif_usb.c:908 [inline] ath9k_hif_usb_alloc_urbs+0x75e/0x1010 drivers/net/wireless/ath/ath9k/hif_usb.c:1019 ath9k_hif_usb_dev_init drivers/net/wireless/ath/ath9k/hif_usb.c:1109 [inline] ath9k_hif_usb_firmware_cb+0x142/0x530 drivers/net/wireless/ath/ath9k/hif_usb.c:1242 request_firmware_work_func+0x12e/0x240 drivers/base/firmware_loader/main.c:1097 process_one_work+0x9af/0x1600 kernel/workqueue.c:2279 worker_thread+0x61d/0x12f0 kernel/workqueue.c:2425 kthread+0x3b4/0x4a0 kernel/kthread.c:313 ret_from_fork+0x22/0x30 arch/x86/entry/entry_64.S:299
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- drivers/net/wireless/ath/ath9k/hif_usb.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/net/wireless/ath/ath9k/hif_usb.c +14 -0
@@ -1329,10 +1329,24 @@ static int send_eject_command(struct usb_interface *interface)static int ath9k_hif_usb_probe (struct usb_interface *interface,const struct usb_device_id *id) { +struct usb_endpoint_descriptor *bulk_in, *bulk_out, *int_in, *int_out;struct usb_device *udev =interface_to_usbdev (interface); +struct usb_host_interface *alt;struct hif_device_usb *hif_dev;int ret =0 ; +/* Verify the expected endpoints are present */ + alt = interface->cur_altsetting; +if (usb_find_common_endpoints (alt, &bulk_in, &bulk_out, &int_in, &int_out) <0 || +usb_endpoint_num (bulk_in) !=USB_WLAN_RX_PIPE || +usb_endpoint_num (bulk_out) !=USB_WLAN_TX_PIPE || +usb_endpoint_num (int_in) !=USB_REG_IN_PIPE || +usb_endpoint_num (int_out) !=USB_REG_OUT_PIPE ) { +dev_err (&udev->dev, +"ath9k_htc: Device endpoint numbers are not the expected ones\n" ); +return -ENODEV ; + } +if (id->driver_info ==STORAGE_DEVICE )return send_eject_command (interface);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 3/73 brcmfmac: return error when getting invalid max_flowrings from dongle
In reply to Sasha LevinFrom: Wright Feng <[email protected]>
[ Upstream commit 2aca4f3734bd717e04943ddf340d49ab62299a00 ]
When firmware hit trap at initialization, host will read abnormal max_flowrings number from dongle, and it will cause kernel panic when doing iowrite to initialize dongle ring.
To detect this error at early stage, we directly return error when getting invalid max_flowrings(>256).
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +4 -0
@@ -1120,6 +1120,10 @@ static int brcmf_pcie_init_ringbuffers(struct brcmf_pciedev_info *devinfo)BRCMF_NROF_H2D_COMMON_MSGRINGS ; max_completionrings =BRCMF_NROF_D2H_COMMON_MSGRINGS ; } +if (max_flowrings >256 ) { +brcmf_err (bus,"invalid max_flowrings(%d)\n" , max_flowrings); +return -EIO ; + }if (devinfo->dma_idx_sz !=0 ) { bufsz = (max_submissionrings + max_completionrings) *
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 8/73 ipmi: fix memleak when unload ipmi driver
In reply to Sasha LevinFrom: Zhang Yuchen <[email protected]>
[ Upstream commit 36992eb6b9b83f7f9cdc8e74fb5799d7b52e83e9 ]
After the IPMI disconnect problem, the memory kept rising and we tried to unload the driver to free the memory. However, only part of the free memory is recovered after the driver is uninstalled. Using ebpf to hook free functions, we find that neither ipmi_user nor ipmi_smi_msg is free, only ipmi_recv_msg is free.
We find that the deliver_smi_err_response call in clean_smi_msgs does the destroy processing on each message from the xmit_msg queue without checking the return value and free ipmi_smi_msg.
deliver_smi_err_response is called only at this location. Adding the free handling has no effect.
To verify, try using ebpf to trace the free function.
$ bpftrace -e 'kretprobe:ipmi_alloc_recv_msg {printf("alloc rcv
%p\n",retval);} kprobe:free_recv_msg {printf("free recv %p\n",
arg0)} kretprobe:ipmi_alloc_smi_msg {printf("alloc smi %p\n",
retval);} kprobe:free_smi_msg {printf("free smi %p\n",arg0)}'Message-Id: <[email protected]>
--- drivers/char/ipmi/ipmi_msghandler.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/char/ipmi/ipmi_msghandler.c +6 -2
@@ -3710,12 +3710,16 @@ static void deliver_smi_err_response(struct ipmi_smi *intf,struct ipmi_smi_msg *msg, unsigned char err) { + int rv; msg->rsp[0 ] = msg->data[0 ] |4 ; msg->rsp[1 ] = msg->data[1 ]; msg->rsp[2 ] = err; msg->rsp_size =3 ; -/* It's an error, so it will never requeue, no need to check return. */ -handle_one_recv_msg (intf, msg); + +/* This will never requeue, but it may ask us to free the message. */ + rv =handle_one_recv_msg (intf, msg); +if (rv ==0 ) +ipmi_free_smi_msg (msg); }static void cleanup_smi_msgs (struct ipmi_smi *intf)
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 20/73 bpf: make sure skb->len != 0 when redirecting to a tunneling device
In reply to Sasha LevinFrom: Stanislav Fomichev <[email protected]>
[ Upstream commit 07ec7b502800ba9f7b8b15cb01dd6556bb41aaca ]
syzkaller managed to trigger another case where skb->len == 0 when we enter __dev_queue_xmit:
WARNING: CPU: 0 PID: 2470 at include/linux/skbuff.h:2576 skb_assert_len include/linux/skbuff.h:2576 [inline] WARNING: CPU: 0 PID: 2470 at include/linux/skbuff.h:2576 __dev_queue_xmit+0x2069/0x35e0 net/core/dev.c:4295 Call Trace: dev_queue_xmit+0x17/0x20 net/core/dev.c:4406 __bpf_tx_skb net/core/filter.c:2115 [inline] __bpf_redirect_no_mac net/core/filter.c:2140 [inline] __bpf_redirect+0x5fb/0xda0 net/core/filter.c:2163 ____bpf_clone_redirect net/core/filter.c:2447 [inline] bpf_clone_redirect+0x247/0x390 net/core/filter.c:2419 bpf_prog_48159a89cb4a9a16+0x59/0x5e bpf_dispatcher_nop_func include/linux/bpf.h:897 [inline] __bpf_prog_run include/linux/filter.h:596 [inline] bpf_prog_run include/linux/filter.h:603 [inline] bpf_test_run+0x46c/0x890 net/bpf/test_run.c:402 bpf_prog_test_run_skb+0xbdc/0x14c0 net/bpf/test_run.c:1170 bpf_prog_test_run+0x345/0x3c0 kernel/bpf/syscall.c:3648 __sys_bpf+0x43a/0x6c0 kernel/bpf/syscall.c:5005 __do_sys_bpf kernel/bpf/syscall.c:5091 [inline] __se_sys_bpf kernel/bpf/syscall.c:5089 [inline] __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5089 do_syscall_64+0x54/0x70 arch/x86/entry/common.c:48 entry_SYSCALL_64_after_hwframe+0x61/0xc6
The reproducer doesn't really reproduce outside of syzkaller environment, so I'm taking a guess here. It looks like we do generate correct ETH_HLEN-sized packet, but we redirect the packet to the tunneling device. Before we do so, we __skb_pull l2 header and arrive again at skb->len == 0. Doesn't seem like we can do anything better than having an explicit check after __skb_pull?
--- net/core/filter.c | 4 ++++ 1 file changed, 4 insertions(+)
net/core/filter.c +4 -0
@@ -2125,6 +2125,10 @@ static int __bpf_redirect_no_mac(struct sk_buff *skb, struct net_device *dev,if (mlen) {__skb_pull (skb, mlen); +if (unlikely (!skb->len)) { +kfree_skb (skb); +return -ERANGE ; + }/* At ingress, the mac header has already been pulled once. * At egress, skb_pospull_rcsum has to be done in case that
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 16/73 HID: apple: enable APPLE_ISO_TILDE_QUIRK for the keyboards of Macs with the T2 chip
In reply to Sasha LevinFrom: Kerem Karabay <[email protected]>
[ Upstream commit 084bc074c231e716cbcb9e8f9db05b17fd3563cf ]
The iso_layout parameter must be manually set to get the driver to swap KEY_102ND and KEY_GRAVE. This patch eliminates the need to do that.
This is safe to do, as Macs with keyboards that do not need the quirk will keep working the same way as the value of hid->country will be different than HID_COUNTRY_INTERNATIONAL_ISO. This was tested by one person with a Mac with the WELLSPRINGT2_J152F keyboard with a layout that does not require the quirk to be set.
--- drivers/hid/hid-apple.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/hid/hid-apple.c +8 -8
@@ -997,21 +997,21 @@ static const struct hid_device_id apple_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS), .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K), - .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL }, + .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132), - .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL }, + .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680), - .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL }, + .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213), - .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL }, + .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K), - .driver_data = APPLE_HAS_FN }, + .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223), - .driver_data = APPLE_HAS_FN }, + .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K), - .driver_data = APPLE_HAS_FN }, + .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F), - .driver_data = APPLE_HAS_FN }, + .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI), .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 18/73 qed (gcc13): use u16 for fid to be big enough
In reply to Sasha LevinFrom: "Jiri Slaby (SUSE)" <[email protected]>
[ Upstream commit 7d84118229bf7f7290438c85caa8e49de52d50c1 ]
gcc 13 correctly reports overflow in qed_grc_dump_addr_range():
In file included from drivers/net/ethernet/qlogic/qed/qed.h:23,
from drivers/net/ethernet/qlogic/qed/qed_debug.c:10:drivers/net/ethernet/qlogic/qed/qed_debug.c: In function 'qed_grc_dump_addr_range':include/linux/qed/qed_if.h:1217:9: error: overflow in conversion from 'int' to 'u8' {aka 'unsigned char'} changes value from '(int)vf_id << 8 | 128' to '128' [-Werror=overflow]
We do:
u8 fid;
...
fid = vf_id << 8 | 128;
Since fid is 16bit (and the stored value above too), fid should be u16, not u8. Fix that.
--- drivers/net/ethernet/qlogic/qed/qed_debug.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/qlogic/qed/qed_debug.c +2 -1
@@ -1972,9 +1972,10 @@ static u32 qed_grc_dump_addr_range(struct qed_hwfn *p_hwfn, u8 split_id) {struct dbg_tools_data *dev_data = &p_hwfn->dbg_info; -u8 port_id =0 , pf_id =0 , vf_id =0 , fid =0 ; +u8 port_id =0 , pf_id =0 , vf_id =0 ;bool read_using_dmae = false;u32 thresh; +u16 fid;if (!dump)return len;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 23/73 wifi: brcmfmac: Fix potential shift-out-of-bounds in brcmf_fw_alloc_request()
In reply to Sasha LevinFrom: Minsuk Kang <[email protected]>
[ Upstream commit 81d17f6f3331f03c8eafdacea68ab773426c1e3c ]
This patch fixes a shift-out-of-bounds in brcmfmac that occurs in BIT(chiprev) when a 'chiprev' provided by the device is too large. It should also not be equal to or greater than BITS_PER_TYPE(u32) as we do bitwise AND with a u32 variable and BIT(chiprev). The patch adds a check that makes the function return NULL if that is the case. Note that the NULL case is later handled by the bus-specific caller, brcmf_usb_probe_cb() or brcmf_usb_reset_resume(), for example.
Found by a modified version of syzkaller.
UBSAN: shift-out-of-bounds in drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c shift exponent 151055786 is too large for 64-bit type 'long unsigned int' CPU: 0 PID: 1885 Comm: kworker/0:2 Tainted: G O 5.14.0+ #132 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014 Workqueue: usb_hub_wq hub_event Call Trace: dump_stack_lvl+0x57/0x7d ubsan_epilogue+0x5/0x40 __ubsan_handle_shift_out_of_bounds.cold+0x53/0xdb ? lock_chain_count+0x20/0x20 brcmf_fw_alloc_request.cold+0x19/0x3ea ? brcmf_fw_get_firmwares+0x250/0x250 ? brcmf_usb_ioctl_resp_wait+0x1a7/0x1f0 brcmf_usb_get_fwname+0x114/0x1a0 ? brcmf_usb_reset_resume+0x120/0x120 ? number+0x6c4/0x9a0 brcmf_c_process_clm_blob+0x168/0x590 ? put_dec+0x90/0x90 ? enable_ptr_key_workfn+0x20/0x20 ? brcmf_common_pd_remove+0x50/0x50 ? rcu_read_lock_sched_held+0xa1/0xd0 brcmf_c_preinit_dcmds+0x673/0xc40 ? brcmf_c_set_joinpref_default+0x100/0x100 ? rcu_read_lock_sched_held+0xa1/0xd0 ? rcu_read_lock_bh_held+0xb0/0xb0 ? lock_acquire+0x19d/0x4e0 ? find_held_lock+0x2d/0x110 ? brcmf_usb_deq+0x1cc/0x260 ? mark_held_locks+0x9f/0xe0 ? lockdep_hardirqs_on_prepare+0x273/0x3e0 ? _raw_spin_unlock_irqrestore+0x47/0x50 ? trace_hardirqs_on+0x1c/0x120 ? brcmf_usb_deq+0x1a7/0x260 ? brcmf_usb_rx_fill_all+0x5a/0xf0 brcmf_attach+0x246/0xd40 ? wiphy_new_nm+0x1476/0x1d50 ? kmemdup+0x30/0x40 brcmf_usb_probe+0x12de/0x1690 ? brcmf_usbdev_qinit.constprop.0+0x470/0x470 usb_probe_interface+0x25f/0x710 really_probe+0x1be/0xa90 __driver_probe_device+0x2ab/0x460 ? usb_match_id.part.0+0x88/0xc0 driver_probe_device+0x49/0x120 __device_attach_driver+0x18a/0x250 ? driver_allows_async_probing+0x120/0x120 bus_for_each_drv+0x123/0x1a0 ? bus_rescan_devices+0x20/0x20 ? lockdep_hardirqs_on_prepare+0x273/0x3e0 ? trace_hardirqs_on+0x1c/0x120 __device_attach+0x207/0x330 ? device_bind_driver+0xb0/0xb0 ? kobject_uevent_env+0x230/0x12c0 bus_probe_device+0x1a2/0x260 device_add+0xa61/0x1ce0 ? __mutex_unlock_slowpath+0xe7/0x660 ? __fw_devlink_link_to_suppliers+0x550/0x550 usb_set_configuration+0x984/0x1770 ? kernfs_create_link+0x175/0x230 usb_generic_driver_probe+0x69/0x90 usb_probe_device+0x9c/0x220 really_probe+0x1be/0xa90 __driver_probe_device+0x2ab/0x460 driver_probe_device+0x49/0x120 __device_attach_driver+0x18a/0x250 ? driver_allows_async_probing+0x120/0x120 bus_for_each_drv+0x123/0x1a0 ? bus_rescan_devices+0x20/0x20 ? lockdep_hardirqs_on_prepare+0x273/0x3e0 ? trace_hardirqs_on+0x1c/0x120 __device_attach+0x207/0x330 ? device_bind_driver+0xb0/0xb0 ? kobject_uevent_env+0x230/0x12c0 bus_probe_device+0x1a2/0x260 device_add+0xa61/0x1ce0 ? __fw_devlink_link_to_suppliers+0x550/0x550 usb_new_device.cold+0x463/0xf66 ? hub_disconnect+0x400/0x400 ? _raw_spin_unlock_irq+0x24/0x30 hub_event+0x10d5/0x3330 ? hub_port_debounce+0x280/0x280 ? __lock_acquire+0x1671/0x5790 ? wq_calc_node_cpumask+0x170/0x2a0 ? lock_release+0x640/0x640 ? rcu_read_lock_sched_held+0xa1/0xd0 ? rcu_read_lock_bh_held+0xb0/0xb0 ? lockdep_hardirqs_on_prepare+0x273/0x3e0 process_one_work+0x873/0x13e0 ? lock_release+0x640/0x640 ? pwq_dec_nr_in_flight+0x320/0x320 ? rwlock_bug.part.0+0x90/0x90 worker_thread+0x8b/0xd10 ? __kthread_parkme+0xd9/0x1d0 ? process_one_work+0x13e0/0x13e0 kthread+0x379/0x450 ? _raw_spin_unlock_irq+0x24/0x30 ? set_kthread_struct+0x100/0x100 ret_from_fork+0x1f/0x30
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +5 -0
@@ -737,6 +737,11 @@ brcmf_fw_alloc_request(u32 chip, u32 chiprev,u32 i, j;char end ='\0' ; +if (chiprev >=BITS_PER_TYPE (u32)) { +brcmf_err ("Invalid chip revision %u\n" , chiprev); +return NULL ; + } +for (i =0 ; i < table_size; i++) {if (mapping_table[i].chipid == chip && mapping_table[i].revmask &BIT (chiprev))
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 24/73 HID: input: do not query XP-PEN Deco LW battery
In reply to Sasha LevinFrom: José Expósito <[email protected]>
[ Upstream commit 037c1aaeb96fe5f778026f4c1ef28b26cf600bfa ]
The XP-PEN Deco LW drawing tablet can be connected by USB cable or using a USB Bluetooth dongle. When it is connected using the dongle, there might be a small delay until the tablet is paired with the dongle.
Fetching the device battery during this delay results in random battery percentage values.
Add a quirk to avoid actively querying the battery percentage and wait for the device to report it on its own.
--- drivers/hid/hid-input.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/hid/hid-input.c +6 -0
@@ -340,6 +340,7 @@ static enum power_supply_property hidinput_battery_props[] = {#define HID_BATTERY_QUIRK_PERCENT (1 << 0)/* always reports percent */ #define HID_BATTERY_QUIRK_FEATURE (1 << 1)/* ask for feature report */ #define HID_BATTERY_QUIRK_IGNORE (1 << 2)/* completely ignore the battery */ +#define HID_BATTERY_QUIRK_AVOID_QUERY (1 << 3)/* do not query the battery */ static const struct hid_device_id hid_battery_quirks[] = { { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
@@ -373,6 +374,8 @@ static const struct hid_device_id hid_battery_quirks[] = { HID_BATTERY_QUIRK_IGNORE }, {HID_USB_DEVICE (USB_VENDOR_ID_ELAN ,USB_DEVICE_ID_ASUS_UX550VE_TOUCHSCREEN ), HID_BATTERY_QUIRK_IGNORE }, + { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_L), + HID_BATTERY_QUIRK_AVOID_QUERY }, { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_ENVY_X360_15), HID_BATTERY_QUIRK_IGNORE }, { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_ENVY_X360_15T_DR100),
@@ -554,6 +557,9 @@ static int hidinput_setup_battery(struct hid_device *dev, unsigned report_type, dev->battery_avoid_query = report_type ==HID_INPUT_REPORT && field->physical ==HID_DG_STYLUS ; +if (quirks &HID_BATTERY_QUIRK_AVOID_QUERY ) + dev->battery_avoid_query = true; + dev->battery =power_supply_register (&dev->dev, psy_desc, &psy_cfg);if (IS_ERR (dev->battery)) { error =PTR_ERR (dev->battery);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 15/73 HID: apple: fix key translations where multiple quirks attempt to translate the same key
In reply to Sasha LevinFrom: Kerem Karabay <[email protected]>
[ Upstream commit 5476fcf7f7b901db1cea92acb1abdd12609e30e1 ]
The hid-apple driver does not support chaining translations or dependencies on other translations. This creates two problems:
1 - In Non-English keyboards of Macs, KEY_102ND and KEY_GRAVE are swapped and the APPLE_ISO_TILDE_QUIRK is used to work around this problem. The quirk is not set for the Macs where these bugs happen yet (see the 2nd patch for that), but this can be forced by setting the iso_layout parameter. Unfortunately, this only partially works. KEY_102ND gets translated to KEY_GRAVE, but KEY_GRAVE does not get translated to KEY_102ND, so both of them end up functioning as KEY_GRAVE. This is because the driver translates the keys as if Fn was pressed and the original is sent if it is not pressed, without any further translations happening on the key[#463]. KEY_GRAVE is present at macbookpro_no_esc_fn_keys[#195], so this is what happens:
- KEY_GRAVE -> KEY_ESC (as if Fn is pressed)
- KEY_GRAVE is returned (Fn isn't pressed, so translation is discarded)
- KEY_GRAVE -> KEY_102ND (this part is not reached!)
...
2 - In case the touchbar does not work, the driver supports sending Escape when Fn+KEY_GRAVE is pressed. As mentioned previously, KEY_102ND is actually KEY_GRAVE and needs to be translated before this happens.
Normally, these are the steps that should happen:
- KEY_102ND -> KEY_GRAVE
- KEY_GRAVE -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
Though this is what happens instead, as dependencies on other translations are not supported:
- KEY_102ND -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
This patch fixes both bugs by ordering the translations correctly and by making the translations continue and not return immediately after translating a key so that chained translations work and translations can depend on other ones.
This patch also simplifies the implementation of the swap_fn_leftctrl option a little bit, as it makes it simply use a normal translation instead adding extra code to translate a key to KEY_FN[#381]. This change wasn't put in another patch as the code that translates the Fn key needs to be changed because of the changes in the patch, and those changes would be discarded with the next patch anyway (the part that originally translates KEY_FN to KEY_LEFTCTRL needs to be made an else-if branch of the part that transltes KEY_LEFTCTRL to KEY_FN).
Note: Line numbers (#XYZ) are for drivers/hid/hid-apple.c at commit 20afcc462579 ("HID: apple: Add "GANSS" to the non-Apple list").
Note: These bugs are only present on Macs with a keyboard with no dedicated escape key and a non-English layout.
--- drivers/hid/hid-apple.c | 102 +++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 58 deletions(-)
drivers/hid/hid-apple.c +44 -58
@@ -314,6 +314,7 @@ static const struct apple_key_translation swapped_option_cmd_keys[] = {static const struct apple_key_translation swapped_fn_leftctrl_keys[] = { {KEY_FN ,KEY_LEFTCTRL }, + {KEY_LEFTCTRL ,KEY_FN }, { } };
@@ -375,24 +376,40 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,struct apple_sc *asc =hid_get_drvdata (hid);const struct apple_key_translation *trans, *table;bool do_translate; -u16 code =0 ; +u16 code = usage->code;unsigned int real_fnmode; -u16 fn_keycode = (swap_fn_leftctrl) ? (KEY_LEFTCTRL ) : (KEY_FN ); - -if (usage->code == fn_keycode) { - asc->fn_on = !!value; -input_event_with_scancode (input, usage->type,KEY_FN , - usage->hid, value); -return 1 ; - } -if (fnmode ==3 ) { real_fnmode = (asc->quirks &APPLE_IS_NON_APPLE ) ?2 :1 ; }else { real_fnmode = fnmode; } +if (swap_fn_leftctrl) { + trans =apple_find_translation (swapped_fn_leftctrl_keys, code); + +if (trans) + code = trans->to; + } + +if (iso_layout >0 || (iso_layout <0 && (asc->quirks &APPLE_ISO_TILDE_QUIRK ) && + hid->country ==HID_COUNTRY_INTERNATIONAL_ISO )) { + trans =apple_find_translation (apple_iso_keyboard, code); + +if (trans) + code = trans->to; + } + +if (swap_opt_cmd) { + trans =apple_find_translation (swapped_option_cmd_keys, code); + +if (trans) + code = trans->to; + } + +if (code ==KEY_FN ) + asc->fn_on = !!value; +if (real_fnmode) { if (hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI || hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO ||
@@ -430,15 +447,18 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,else table = apple_fn_keys; - trans =apple_find_translation (table, usage->code); + trans =apple_find_translation (table, code);if (trans) { -if (test_bit (trans->from, input->key)) +bool from_is_set =test_bit (trans->from, input->key); +bool to_is_set =test_bit (trans->to, input->key); + +if (from_is_set) code = trans->from; -else if (test_bit (trans->to, input->key)) +else if (to_is_set) code = trans->to; -if (!code) { +if (!(from_is_set || to_is_set)) {if (trans->flags &APPLE_FLAG_FKEY ) {switch (real_fnmode) {case 1 :
@@ -455,62 +475,31 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, do_translate = asc->fn_on; } - code = do_translate ? trans->to : trans->from; +if (do_translate) + code = trans->to; } - -input_event_with_scancode (input, usage->type, code, - usage->hid, value); -return 1 ; }if (asc->quirks &APPLE_NUMLOCK_EMULATION && - (test_bit (usage->code, asc->pressed_numlock) || + (test_bit (code, asc->pressed_numlock) ||test_bit (LED_NUML , input->led))) { - trans =apple_find_translation (powerbook_numlock_keys, - usage->code); + trans =apple_find_translation (powerbook_numlock_keys, code);if (trans) {if (value) -set_bit (usage->code, - asc->pressed_numlock); +set_bit (code, asc->pressed_numlock);else -clear_bit (usage->code, - asc->pressed_numlock); +clear_bit (code, asc->pressed_numlock); -input_event_with_scancode (input, usage->type, - trans->to, usage->hid, value); + code = trans->to; } - -return 1 ; } } -if (iso_layout >0 || (iso_layout <0 && (asc->quirks &APPLE_ISO_TILDE_QUIRK ) && - hid->country ==HID_COUNTRY_INTERNATIONAL_ISO )) { - trans =apple_find_translation (apple_iso_keyboard, usage->code); -if (trans) { -input_event_with_scancode (input, usage->type, - trans->to, usage->hid, value); -return 1 ; - } - } +if (usage->code != code) { +input_event_with_scancode (input, usage->type, code, usage->hid, value); -if (swap_opt_cmd) { - trans =apple_find_translation (swapped_option_cmd_keys, usage->code); -if (trans) { -input_event_with_scancode (input, usage->type, - trans->to, usage->hid, value); -return 1 ; - } - } - -if (swap_fn_leftctrl) { - trans =apple_find_translation (swapped_fn_leftctrl_keys, usage->code); -if (trans) { -input_event_with_scancode (input, usage->type, - trans->to, usage->hid, value); -return 1 ; - } +return 1 ; }return 0 ;
@@ -640,9 +629,6 @@ static void apple_setup_input(struct input_dev *input)apple_setup_key_translation (input, apple2021_fn_keys);apple_setup_key_translation (input, macbookpro_no_esc_fn_keys);apple_setup_key_translation (input, macbookpro_dedicated_esc_fn_keys); - -if (swap_fn_leftctrl) -apple_setup_key_translation (input, swapped_fn_leftctrl_keys); } static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi,
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 36/73 drivers/md/md-bitmap: check the return value of md_bitmap_get_counter()
In reply to Sasha LevinFrom: Li Zhong <[email protected]>
[ Upstream commit 3bd548e5b819b8c0f2c9085de775c5c7bff9052f ]
Check the return value of md_bitmap_get_counter() in case it returns NULL pointer, which will result in a null pointer dereference.
v2: update the check to include other dereference
--- drivers/md/md-bitmap.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)
drivers/md/md-bitmap.c +15 -12
@@ -2195,20 +2195,23 @@ int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,if (set) { bmc_new =md_bitmap_get_counter (&bitmap->counts, block, &new_blocks,1 ); -if (*bmc_new ==0 ) { -/* need to set on-disk bits too. */ -sector_t end = block + new_blocks; -sector_t start = block >> chunkshift; - start <<= chunkshift; -while (start < end) { -md_bitmap_file_set_bit (bitmap, block); - start +=1 << chunkshift; +if (bmc_new) { +if (*bmc_new ==0 ) { +/* need to set on-disk bits too. */ +sector_t end = block + new_blocks; +sector_t start = block >> chunkshift; + + start <<= chunkshift; +while (start < end) { +md_bitmap_file_set_bit (bitmap, block); + start +=1 << chunkshift; + } + *bmc_new =2 ; +md_bitmap_count_page (&bitmap->counts, block,1 ); +md_bitmap_set_pending (&bitmap->counts, block); } - *bmc_new =2 ; -md_bitmap_count_page (&bitmap->counts, block,1 ); -md_bitmap_set_pending (&bitmap->counts, block); + *bmc_new |=NEEDED_MASK ; } - *bmc_new |=NEEDED_MASK ;if (new_blocks < old_blocks) old_blocks = new_blocks; }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 37/73 md/raid0, raid10: Don't set discard sectors for request queue
In reply to Sasha LevinFrom: Xiao Ni <[email protected]>
[ Upstream commit 8e1a2279ca2b0485cc379a153d02a9793f74a48f ]
It should use disk_stack_limits to get a proper max_discard_sectors rather than setting a value by stack drivers.
And there is a bug. If all member disks are rotational devices, raid0/raid10 set max_discard_sectors. So the member devices are not ssd/nvme, but raid0/raid10 export the wrong value. It reports warning messages in function __blkdev_issue_discard when mkfs.xfs like this:
[ 4616.022599] ------------[ cut here ]------------ [ 4616.027779] WARNING: CPU: 4 PID: 99634 at block/blk-lib.c:50 __blkdev_issue_discard+0x16a/0x1a0 [ 4616.140663] RIP: 0010:__blkdev_issue_discard+0x16a/0x1a0 [ 4616.146601] Code: 24 4c 89 20 31 c0 e9 fe fe ff ff c1 e8 09 8d 48 ff 4c 89 f0 4c 09 e8 48 85 c1 0f 84 55 ff ff ff b8 ea ff ff ff e9 df fe ff ff <0f> 0b 48 8d 74 24 08 e8 ea d6 00 00 48 c7 c6 20 1e 89 ab 48 c7 c7 [ 4616.167567] RSP: 0018:ffffaab88cbffca8 EFLAGS: 00010246 [ 4616.173406] RAX: ffff9ba1f9e44678 RBX: 0000000000000000 RCX: ffff9ba1c9792080 [ 4616.181376] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff9ba1c9792080 [ 4616.189345] RBP: 0000000000000cc0 R08: ffffaab88cbffd10 R09: 0000000000000000 [ 4616.197317] R10: 0000000000000012 R11: 0000000000000000 R12: 0000000000000000 [ 4616.205288] R13: 0000000000400000 R14: 0000000000000cc0 R15: ffff9ba1c9792080 [ 4616.213259] FS: 00007f9a5534e980(0000) GS:ffff9ba1b7c80000(0000) knlGS:0000000000000000 [ 4616.222298] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 4616.228719] CR2: 000055a390a4c518 CR3: 0000000123e40006 CR4: 00000000001706e0 [ 4616.236689] Call Trace: [ 4616.239428] blkdev_issue_discard+0x52/0xb0 [ 4616.244108] blkdev_common_ioctl+0x43c/0xa00 [ 4616.248883] blkdev_ioctl+0x116/0x280 [ 4616.252977] __x64_sys_ioctl+0x8a/0xc0 [ 4616.257163] do_syscall_64+0x5c/0x90 [ 4616.261164] ? handle_mm_fault+0xc5/0x2a0 [ 4616.265652] ? do_user_addr_fault+0x1d8/0x690 [ 4616.270527] ? do_syscall_64+0x69/0x90 [ 4616.274717] ? exc_page_fault+0x62/0x150 [ 4616.279097] entry_SYSCALL_64_after_hwframe+0x63/0xcd [ 4616.284748] RIP: 0033:0x7f9a55398c6b
--- drivers/md/raid0.c | 1 - drivers/md/raid10.c | 2 -- 2 files changed, 3 deletions(-)
drivers/md/raid0.c +0 -1
@@ -398,7 +398,6 @@ static int raid0_run(struct mddev *mddev)blk_queue_max_hw_sectors (mddev->queue, mddev->chunk_sectors);blk_queue_max_write_zeroes_sectors (mddev->queue, mddev->chunk_sectors); -blk_queue_max_discard_sectors (mddev->queue,UINT_MAX );blk_queue_io_min (mddev->queue, mddev->chunk_sectors <<9 ); blk_queue_io_opt(mddev->queue,
drivers/md/raid10.c +0 -2
@@ -4104,8 +4104,6 @@ static int raid10_run(struct mddev *mddev) conf->thread =NULL ;if (mddev->queue) { -blk_queue_max_discard_sectors (mddev->queue, -UINT_MAX );blk_queue_max_write_zeroes_sectors (mddev->queue,0 );blk_queue_io_min (mddev->queue, mddev->chunk_sectors <<9 );raid10_set_io_opt (conf);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 38/73 md/raid1: stop mdx_raid1 thread when raid1 array run failed
In reply to Sasha LevinFrom: Jiang Li <[email protected]>
[ Upstream commit b611ad14006e5be2170d9e8e611bf49dff288911 ]
fail run raid1 array when we assemble array with the inactive disk only, but the mdx_raid1 thread were not stop, Even if the associated resources have been released. it will caused a NULL dereference when we do poweroff.
This causes the following Oops:
[ 287.587787] BUG: kernel NULL pointer dereference, address: 0000000000000070
[ 287.594762] #PF: supervisor read access in kernel mode
[ 287.599912] #PF: error_code(0x0000) - not-present page
[ 287.605061] PGD 0 P4D 0
[ 287.607612] Oops: 0000 [#1] SMP NOPTI
[ 287.611287] CPU: 3 PID: 5265 Comm: md0_raid1 Tainted: G U 5.10.146 #0
[ 287.619029] Hardware name: xxxxxxx/To be filled by O.E.M, BIOS 5.19 06/16/2022
[ 287.626775] RIP: 0010:md_check_recovery+0x57/0x500 [md_mod]
[ 287.632357] Code: fe 01 00 00 48 83 bb 10 03 00 00 00 74 08 48 89 ......
[ 287.651118] RSP: 0018:ffffc90000433d78 EFLAGS: 00010202
[ 287.656347] RAX: 0000000000000000 RBX: ffff888105986800 RCX: 0000000000000000
[ 287.663491] RDX: ffffc90000433bb0 RSI: 00000000ffffefff RDI: ffff888105986800
[ 287.670634] RBP: ffffc90000433da0 R08: 0000000000000000 R09: c0000000ffffefff
[ 287.677771] R10: 0000000000000001 R11: ffffc90000433ba8 R12: ffff888105986800
[ 287.684907] R13: 0000000000000000 R14: fffffffffffffe00 R15: ffff888100b6b500
[ 287.692052] FS: 0000000000000000(0000) GS:ffff888277f80000(0000) knlGS:0000000000000000
[ 287.700149] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 287.705897] CR2: 0000000000000070 CR3: 000000000320a000 CR4: 0000000000350ee0
[ 287.713033] Call Trace:
[ 287.715498] raid1d+0x6c/0xbbb [raid1]
[ 287.719256] ? __schedule+0x1ff/0x760
[ 287.722930] ? schedule+0x3b/0xb0
[ 287.726260] ? schedule_timeout+0x1ed/0x290
[ 287.730456] ? __switch_to+0x11f/0x400
[ 287.734219] md_thread+0xe9/0x140 [md_mod]
[ 287.738328] ? md_thread+0xe9/0x140 [md_mod]
[ 287.742601] ? wait_woken+0x80/0x80
[ 287.746097] ? md_register_thread+0xe0/0xe0 [md_mod]
[ 287.751064] kthread+0x11a/0x140
[ 287.754300] ? kthread_park+0x90/0x90
[ 287.757974] ret_from_fork+0x1f/0x30In fact, when raid1 array run fail, we need to domd_unregister_thread() before raid1_free().
--- drivers/md/raid1.c | 1 + 1 file changed, 1 insertion(+)
drivers/md/raid1.c +1 -0
@@ -3159,6 +3159,7 @@ static int raid1_run(struct mddev *mddev)* RAID1 needs at least one disk in active */ if (conf->raid_disks - mddev->degraded <1 ) { +md_unregister_thread (&conf->thread); ret = -EINVAL ; goto abort; }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 42/73 net: add atomic_long_t to net_device_stats fields
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit 6c1c5097781f563b70a81683ea6fdac21637573b ]
Long standing KCSAN issues are caused by data-race around some dev->stats changes.
Most performance critical paths already use per-cpu variables, or per-queue ones.
It is reasonable (and more correct) to use atomic operations for the slow paths.
This patch adds an union for each field of net_device_stats, so that we can convert paths that are not yet protected by a spinlock or a mutex.
netdev_stats_to_stats64() no longer has an #if BITS_PER_LONG==64
Note that the memcpy() we were using on 64bit arches had no provision to avoid load-tearing,
while atomic_long_read() is providing the needed protection at no cost.
--- include/linux/netdevice.h | 58 +++++++++++++++++++++++---------------- include/net/dst.h | 5 ++-- net/core/dev.c | 14 ++-------- 3 files changed, 40 insertions(+), 37 deletions(-)
include/linux/netdevice.h +35 -23
@@ -171,31 +171,38 @@ static inline bool dev_xmit_complete(int rc)* (unsigned long) so they can be read and written atomically. */ +#define NET_DEV_STAT (FIELD ) \ + union { \ + unsigned long FIELD; \ + atomic_long_t __##FIELD; \ + } +struct net_device_stats { -unsigned long rx_packets; -unsigned long tx_packets; -unsigned long rx_bytes; -unsigned long tx_bytes; -unsigned long rx_errors; -unsigned long tx_errors; -unsigned long rx_dropped; -unsigned long tx_dropped; -unsigned long multicast; -unsigned long collisions; -unsigned long rx_length_errors; -unsigned long rx_over_errors; -unsigned long rx_crc_errors; -unsigned long rx_frame_errors; -unsigned long rx_fifo_errors; -unsigned long rx_missed_errors; -unsigned long tx_aborted_errors; -unsigned long tx_carrier_errors; -unsigned long tx_fifo_errors; -unsigned long tx_heartbeat_errors; -unsigned long tx_window_errors; -unsigned long rx_compressed; -unsigned long tx_compressed; +NET_DEV_STAT (rx_packets); +NET_DEV_STAT (tx_packets); +NET_DEV_STAT (rx_bytes); +NET_DEV_STAT (tx_bytes); +NET_DEV_STAT (rx_errors); +NET_DEV_STAT (tx_errors); +NET_DEV_STAT (rx_dropped); +NET_DEV_STAT (tx_dropped); +NET_DEV_STAT (multicast); +NET_DEV_STAT (collisions); +NET_DEV_STAT (rx_length_errors); +NET_DEV_STAT (rx_over_errors); +NET_DEV_STAT (rx_crc_errors); +NET_DEV_STAT (rx_frame_errors); +NET_DEV_STAT (rx_fifo_errors); +NET_DEV_STAT (rx_missed_errors); +NET_DEV_STAT (tx_aborted_errors); +NET_DEV_STAT (tx_carrier_errors); +NET_DEV_STAT (tx_fifo_errors); +NET_DEV_STAT (tx_heartbeat_errors); +NET_DEV_STAT (tx_window_errors); +NET_DEV_STAT (rx_compressed); +NET_DEV_STAT (tx_compressed); }; +#undef NET_DEV_STAT/* per-cpu stats, allocated on demand. * Try to fit them in a single cache line, for dev_get_stats() sake.
@@ -5143,4 +5150,9 @@ extern struct list_head ptype_base[PTYPE_HASH_SIZE] __read_mostly;extern struct net_device *blackhole_netdev; +/* Note: Avoid these macros in fast path, prefer per-cpu or per-queue counters. */ +#define DEV_STATS_INC (DEV ,FIELD ) atomic_long_inc(&(DEV)->stats.__##FIELD) +#define DEV_STATS_ADD (DEV ,FIELD ,VAL ) \ + atomic_long_add((VAL), &(DEV)->stats.__##FIELD) +#endif /* _LINUX_NETDEVICE_H */
include/net/dst.h +2 -3
@@ -362,9 +362,8 @@ static inline void __skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev,static inline void skb_tunnel_rx (struct sk_buff *skb,struct net_device *dev,struct net *net) { -/* TODO : stats should be SMP safe */ - dev->stats.rx_packets++; - dev->stats.rx_bytes += skb->len; +DEV_STATS_INC (dev, rx_packets); +DEV_STATS_ADD (dev, rx_bytes, skb->len);__skb_tunnel_rx (skb, dev, net); }
net/core/dev.c +3 -11
@@ -10398,24 +10398,16 @@ void netdev_run_todo(void)void netdev_stats_to_stats64 (struct rtnl_link_stats64 *stats64,const struct net_device_stats *netdev_stats) { -#if BITS_PER_LONG ==64 -BUILD_BUG_ON (sizeof (*stats64) <sizeof (*netdev_stats)); -memcpy (stats64, netdev_stats,sizeof (*netdev_stats)); -/* zero out counters that only exist in rtnl_link_stats64 */ -memset ((char *)stats64 +sizeof (*netdev_stats),0 , -sizeof (*stats64) -sizeof (*netdev_stats)); -#else -size_t i, n =sizeof (*netdev_stats) /sizeof (unsigned long ); -const unsigned long *src = (const unsigned long *)netdev_stats; +size_t i, n =sizeof (*netdev_stats) /sizeof (atomic_long_t); +const atomic_long_t *src = (atomic_long_t *)netdev_stats;u64 *dst = (u64 *)stats64;BUILD_BUG_ON (n >sizeof (*stats64) /sizeof (u64));for (i =0 ; i < n; i++) - dst[i] = src[i]; + dst[i] =atomic_long_read (&src[i]);/* zero out counters that only exist in rtnl_link_stats64 */ memset ((char *)stats64 + n *sizeof (u64),0 ,sizeof (*stats64) - n *sizeof (u64)); -#endif }EXPORT_SYMBOL (netdev_stats_to_stats64);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 43/73 ipv6/sit: use DEV_STATS_INC() to avoid data-races
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit cb34b7cf17ecf33499c9298943f85af247abc1e9 ]
syzbot/KCSAN reported that multiple cpus are updating dev->stats.tx_error concurrently.
This is because sit tunnels are NETIF_F_LLTX, meaning their ndo_start_xmit() is not protected by a spinlock.
While original KCSAN report was about tx path, rx path has the same issue.
--- net/ipv6/sit.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
net/ipv6/sit.c +11 -11
@@ -694,7 +694,7 @@ static int ipip6_rcv(struct sk_buff *skb) skb->dev = tunnel->dev;if (packet_is_spoofed (skb, iph, tunnel)) { - tunnel->dev->stats.rx_errors++; +DEV_STATS_INC (tunnel->dev, rx_errors); goto out; }
@@ -714,8 +714,8 @@ static int ipip6_rcv(struct sk_buff *skb)net_info_ratelimited ("non-ECT from %pI4 with TOS=%#x\n" , &iph->saddr, iph->tos);if (err >1 ) { - ++tunnel->dev->stats.rx_frame_errors; - ++tunnel->dev->stats.rx_errors; +DEV_STATS_INC (tunnel->dev, rx_frame_errors); +DEV_STATS_INC (tunnel->dev, rx_errors); goto out; } }
@@ -942,7 +942,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,if (!rt) { rt =ip_route_output_flow (tunnel->net, &fl4,NULL );if (IS_ERR (rt)) { - dev->stats.tx_carrier_errors++; +DEV_STATS_INC (dev, tx_carrier_errors); goto tx_error_icmp; }dst_cache_set_ip4 (&tunnel->dst_cache, &rt->dst, fl4.saddr);
@@ -950,14 +950,14 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,if (rt->rt_type !=RTN_UNICAST && rt->rt_type !=RTN_LOCAL ) {ip_rt_put (rt); - dev->stats.tx_carrier_errors++; +DEV_STATS_INC (dev, tx_carrier_errors); goto tx_error_icmp; } tdev = rt->dst.dev;if (tdev == dev) {ip_rt_put (rt); - dev->stats.collisions++; +DEV_STATS_INC (dev, collisions); goto tx_error; }
@@ -970,7 +970,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, mtu =dst_mtu (&rt->dst) - t_hlen;if (mtu <IPV4_MIN_MTU ) { - dev->stats.collisions++; +DEV_STATS_INC (dev, collisions);ip_rt_put (rt); goto tx_error; }
@@ -1009,7 +1009,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,struct sk_buff *new_skb =skb_realloc_headroom (skb, max_headroom);if (!new_skb) {ip_rt_put (rt); - dev->stats.tx_dropped++; +DEV_STATS_INC (dev, tx_dropped);kfree_skb (skb);return NETDEV_TX_OK ; }
@@ -1039,7 +1039,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,dst_link_failure (skb); tx_error:kfree_skb (skb); - dev->stats.tx_errors++; +DEV_STATS_INC (dev, tx_errors);return NETDEV_TX_OK ; }
@@ -1058,7 +1058,7 @@ static netdev_tx_t sit_tunnel_xmit__(struct sk_buff *skb,return NETDEV_TX_OK ; tx_error:kfree_skb (skb); - dev->stats.tx_errors++; +DEV_STATS_INC (dev, tx_errors);return NETDEV_TX_OK ; }
@@ -1087,7 +1087,7 @@ static netdev_tx_t sit_tunnel_xmit(struct sk_buff *skb,return NETDEV_TX_OK ; tx_err: - dev->stats.tx_errors++; +DEV_STATS_INC (dev, tx_errors);kfree_skb (skb);return NETDEV_TX_OK ;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 44/73 mrp: introduce active flags to prevent UAF when applicant uninit
In reply to Sasha LevinFrom: Schspa Shi <[email protected]>
[ Upstream commit ab0377803dafc58f1e22296708c1c28e309414d6 ]
The caller of del_timer_sync must prevent restarting of the timer, If we have no this synchronization, there is a small probability that the cancellation will not be successful.
And syzbot report the fellowing crash:
==================================================================
BUG: KASAN: use-after-free in hlist_add_head include/linux/list.h:929 [inline] BUG: KASAN: use-after-free in enqueue_timer+0x18/0xa4 kernel/time/timer.c:605
Write at addr f9ff000024df6058 by task syz-fuzzer/2256 Pointer tag: [f9], memory tag: [fe]
CPU: 1 PID: 2256 Comm: syz-fuzzer Not tainted 6.1.0-rc5-syzkaller-00008- ge01d50cbd6ee #0 Hardware name: linux,dummy-virt (DT) Call trace: dump_backtrace.part.0+0xe0/0xf0 arch/arm64/kernel/stacktrace.c:156 dump_backtrace arch/arm64/kernel/stacktrace.c:162 [inline] show_stack+0x18/0x40 arch/arm64/kernel/stacktrace.c:163 __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x68/0x84 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:284 [inline] print_report+0x1a8/0x4a0 mm/kasan/report.c:395 kasan_report+0x94/0xb4 mm/kasan/report.c:495 __do_kernel_fault+0x164/0x1e0 arch/arm64/mm/fault.c:320 do_bad_area arch/arm64/mm/fault.c:473 [inline] do_tag_check_fault+0x78/0x8c arch/arm64/mm/fault.c:749 do_mem_abort+0x44/0x94 arch/arm64/mm/fault.c:825 el1_abort+0x40/0x60 arch/arm64/kernel/entry-common.c:367 el1h_64_sync_handler+0xd8/0xe4 arch/arm64/kernel/entry-common.c:427 el1h_64_sync+0x64/0x68 arch/arm64/kernel/entry.S:576 hlist_add_head include/linux/list.h:929 [inline] enqueue_timer+0x18/0xa4 kernel/time/timer.c:605 mod_timer+0x14/0x20 kernel/time/timer.c:1161 mrp_periodic_timer_arm net/802/mrp.c:614 [inline] mrp_periodic_timer+0xa0/0xc0 net/802/mrp.c:627 call_timer_fn.constprop.0+0x24/0x80 kernel/time/timer.c:1474 expire_timers+0x98/0xc4 kernel/time/timer.c:1519
To fix it, we can introduce a new active flags to make sure the timer will not restart.
--- include/net/mrp.h | 1 + net/802/mrp.c | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-)
include/net/mrp.h +1 -0
@@ -124,6 +124,7 @@ struct mrp_applicant {struct sk_buff *pdu;struct rb_root mad;struct rcu_head rcu; +bool active; };struct mrp_port {
net/802/mrp.c +13 -5
@@ -606,7 +606,10 @@ static void mrp_join_timer(struct timer_list *t)spin_unlock (&app->lock);mrp_queue_xmit (app); -mrp_join_timer_arm (app); +spin_lock (&app->lock); +if (likely (app->active)) +mrp_join_timer_arm (app); +spin_unlock (&app->lock); }static void mrp_periodic_timer_arm (struct mrp_applicant *app)
@@ -620,11 +623,12 @@ static void mrp_periodic_timer(struct timer_list *t)struct mrp_applicant *app =from_timer (app, t, periodic_timer);spin_lock (&app->lock); -mrp_mad_event (app,MRP_EVENT_PERIODIC ); -mrp_pdu_queue (app); +if (likely (app->active)) { +mrp_mad_event (app,MRP_EVENT_PERIODIC ); +mrp_pdu_queue (app); +mrp_periodic_timer_arm (app); + }spin_unlock (&app->lock); - -mrp_periodic_timer_arm (app); }static int mrp_pdu_parse_end_mark (struct sk_buff *skb,int *offset)
@@ -872,6 +876,7 @@ int mrp_init_applicant(struct net_device *dev, struct mrp_application *appl) app->dev = dev; app->app = appl; app->mad =RB_ROOT ; + app->active = true;spin_lock_init (&app->lock);skb_queue_head_init (&app->queue);rcu_assign_pointer (dev->mrp_port->applicants[appl->type], app);
@@ -900,6 +905,9 @@ void mrp_uninit_applicant(struct net_device *dev, struct mrp_application *appl)RCU_INIT_POINTER (port->applicants[appl->type],NULL ); +spin_lock_bh (&app->lock); + app->active = false; +spin_unlock_bh (&app->lock);/* Delete timer and generate a final TX event to flush out * all pending messages before the applicant is gone. */
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 46/73 ppp: associate skb with a device at tx
In reply to Sasha LevinFrom: Stanislav Fomichev <[email protected]>
[ Upstream commit 9f225444467b98579cf28d94f4ad053460dfdb84 ]
Syzkaller triggered flow dissector warning with the following:
r0 = openat$ppp(0xffffffffffffff9c, &(0x7f0000000000), 0xc0802, 0x0)
ioctl$PPPIOCNEWUNIT(r0, 0xc004743e, &(0x7f00000000c0))
ioctl$PPPIOCSACTIVE(r0, 0x40107446, &(0x7f0000000240)={0x2, &(0x7f0000000180)=[{0x20, 0x0, 0x0, 0xfffff034}, {0x6}]}) pwritev(r0, &(0x7f0000000040)=[{&(0x7f0000000140)='\x00!', 0x2}], 0x1, 0x0, 0x0)
[ 9.485814] WARNING: CPU: 3 PID: 329 at net/core/flow_dissector.c:1016 __skb_flow_dissect+0x1ee0/0x1fa0 [ 9.485929] skb_get_poff+0x53/0xa0 [ 9.485937] bpf_skb_get_pay_offset+0xe/0x20 [ 9.485944] ? ppp_send_frame+0xc2/0x5b0 [ 9.485949] ? _raw_spin_unlock_irqrestore+0x40/0x60 [ 9.485958] ? __ppp_xmit_process+0x7a/0xe0 [ 9.485968] ? ppp_xmit_process+0x5b/0xb0 [ 9.485974] ? ppp_write+0x12a/0x190 [ 9.485981] ? do_iter_write+0x18e/0x2d0 [ 9.485987] ? __import_iovec+0x30/0x130 [ 9.485997] ? do_pwritev+0x1b6/0x240 [ 9.486016] ? trace_hardirqs_on+0x47/0x50 [ 9.486023] ? __x64_sys_pwritev+0x24/0x30 [ 9.486026] ? do_syscall_64+0x3d/0x80 [ 9.486031] ? entry_SYSCALL_64_after_hwframe+0x63/0xcd
Flow dissector tries to find skb net namespace either via device or via socket. Neigher is set in ppp_send_frame, so let's manually use ppp->dev.
--- drivers/net/ppp/ppp_generic.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ppp/ppp_generic.c +2 -0
@@ -1743,6 +1743,8 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)int len;unsigned char *cp; + skb->dev = ppp->dev; +if (proto <0x8000 ) {#ifdef CONFIG_PPP_FILTER /* check if we should pass this packet */
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 47/73 bpf: Fix a BTF_ID_LIST bug with CONFIG_DEBUG_INFO_BTF not set
In reply to Sasha LevinFrom: Yonghong Song <[email protected]>
[ Upstream commit beb3d47d1d3d7185bb401af628ad32ee204a9526 ]
With CONFIG_DEBUG_INFO_BTF not set, we hit the following compilation error,
/.../kernel/bpf/verifier.c:8196:23: error: array index 6 is past the end of the array (that has type 'u32[5]' (aka 'unsigned int[5]')) [-Werror,-Warray-bounds]
if (meta->func_id == special_kfunc_list[KF_bpf_cast_to_kern_ctx])
^ ~~~~~~~~~~~~~~~~~~~~~~~
/.../kernel/bpf/verifier.c:8174:1: note: array 'special_kfunc_list' declared here
BTF_ID_LIST(special_kfunc_list)
^
/.../include/linux/btf_ids.h:207:27: note: expanded from macro 'BTF_ID_LIST'
#define BTF_ID_LIST(name) static u32 __maybe_unused name[5];
^
/.../kernel/bpf/verifier.c:8443:19: error: array index 5 is past the end of the array
(that has type 'u32[5]' (aka 'unsigned int[5]')) [-Werror,-Warray-bounds]
btf_id == special_kfunc_list[KF_bpf_list_pop_back];
^ ~~~~~~~~~~~~~~~~~~~~ /.../kernel/bpf/verifier.c:8174:1: note: array 'special_kfunc_list' declared here BTF_ID_LIST(special_kfunc_list)
^
/.../include/linux/btf_ids.h:207:27: note: expanded from macro 'BTF_ID_LIST' #define BTF_ID_LIST(name) static u32 __maybe_unused name[5];
...
Fix the problem by increase the size of BTF_ID_LIST to 16 to avoid compilation error and also prevent potentially unintended issue due to out-of-bound access.
--- include/linux/btf_ids.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/btf_ids.h +1 -1
@@ -204,7 +204,7 @@ extern struct btf_id_set8 name;#else -#define BTF_ID_LIST (name) static u32 __maybe_unused name[5]; +#define BTF_ID_LIST (name) static u32 __maybe_unused name[16];#define BTF_ID (prefix, name)#define BTF_ID_FLAGS (prefix, name, ...)#define BTF_ID_UNUSED
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 49/73 ethtool: avoiding integer overflow in ethtool_phys_id()
In reply to Sasha LevinFrom: Maxim Korotkov <[email protected]>
[ Upstream commit 64a8f8f7127da228d59a39e2c5e75f86590f90b4 ]
The value of an arithmetic expression "n * id.data" is subject to possible overflow due to a failure to cast operands to a larger data type before performing arithmetic. Used macro for multiplication instead operator for avoiding overflow.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- net/ethtool/ioctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ethtool/ioctl.c +2 -1
@@ -2007,7 +2007,8 @@ static int ethtool_phys_id(struct net_device *dev, void __user *useraddr) }else {/* Driver expects to be called at twice the frequency in rc */ int n = rc *2 , interval =HZ / n; -u64 count = n * id.data, i =0 ; +u64 count =mul_u32_u32 (n, id.data); +u64 i =0 ; do { rtnl_lock();
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 50/73 media: dvb-frontends: fix leak of memory fw
In reply to Sasha LevinFrom: Yan Lei <[email protected]>
[ Upstream commit a15fe8d9f1bf460a804bcf18a890bfd2cf0d5caa ]
--- drivers/media/dvb-frontends/bcm3510.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/dvb-frontends/bcm3510.c +1 -0
@@ -649,6 +649,7 @@ static int bcm3510_download_firmware(struct dvb_frontend* fe)deb_info ("firmware chunk, addr: 0x%04x, len: 0x%04x, total length: 0x%04zx\n" ,addr,len,fw->size);if ((ret =bcm3510_write_ram (st,addr,&b[i+4 ],len)) <0 ) {err ("firmware download failed: %d\n" ,ret); +release_firmware (fw);return ret; } i +=4 + len;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 48/73 bpf: Prevent decl_tag from being referenced in func_proto arg
In reply to Sasha LevinFrom: Stanislav Fomichev <[email protected]>
[ Upstream commit f17472d4599697d701aa239b4c475a506bccfd19 ]
Syzkaller managed to hit another decl_tag issue:
btf_func_proto_check kernel/bpf/btf.c:4506 [inline] btf_check_all_types kernel/bpf/btf.c:4734 [inline] btf_parse_type_sec+0x1175/0x1980 kernel/bpf/btf.c:4763 btf_parse kernel/bpf/btf.c:5042 [inline] btf_new_fd+0x65a/0xb00 kernel/bpf/btf.c:6709 bpf_btf_load+0x6f/0x90 kernel/bpf/syscall.c:4342 __sys_bpf+0x50a/0x6c0 kernel/bpf/syscall.c:5034 __do_sys_bpf kernel/bpf/syscall.c:5093 [inline] __se_sys_bpf kernel/bpf/syscall.c:5091 [inline] __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5091 do_syscall_64+0x54/0x70 arch/x86/entry/common.c:48
This seems similar to commit ea68376c8bed ("bpf: prevent decl_tag from being referenced in func_proto") but for the argument.
--- kernel/bpf/btf.c | 5 +++++ 1 file changed, 5 insertions(+)
kernel/bpf/btf.c +5 -0
@@ -4481,6 +4481,11 @@ static int btf_func_proto_check(struct btf_verifier_env *env,break ; } +if (btf_type_is_resolve_source_only (arg_type)) { +btf_verifier_log_type (env, t,"Invalid arg#%u" , i +1 ); +return -EINVAL ; + } +if (args[i].name_off && (!btf_name_offset_valid (btf, args[i].name_off) || !btf_name_valid_identifier (btf, args[i].name_off))) {
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 52/73 media: dvb-usb: fix memory leak in dvb_usb_adapter_init()
In reply to Sasha LevinFrom: Mazin Al Haddad <[email protected]>
[ Upstream commit 94d90fb06b94a90c176270d38861bcba34ce377d ]
Syzbot reports a memory leak in "dvb_usb_adapter_init()". The leak is due to not accounting for and freeing current iteration's adapter->priv in case of an error. Currently if an error occurs, it will exit before incrementing "num_adapters_initalized", which is used as a reference counter to free all adap->priv in "dvb_usb_adapter_exit()". There are multiple error paths that can exit from before incrementing the counter. Including the error handling paths for "dvb_usb_adapter_stream_init()", "dvb_usb_adapter_dvb_init()" and "dvb_usb_adapter_frontend_init()" within "dvb_usb_adapter_init()".
This means that in case of an error in any of these functions the current iteration is not accounted for and the current iteration's adap->priv is not freed.
Fix this by freeing the current iteration's adap->priv in the "stream_init_err:" label in the error path. The rest of the (accounted for) adap->priv objects are freed in dvb_usb_adapter_exit() as expected using the num_adapters_initalized variable.
Syzbot report:
BUG: memory leak
unreferenced object 0xffff8881172f1a00 (size 512):
comm "kworker/0:2", pid 139, jiffies 4294994873 (age 10.960s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff844af012>] dvb_usb_adapter_init drivers/media/usb/dvb-usb/dvb-usb-init.c:75 [inline]
[<ffffffff844af012>] dvb_usb_init drivers/media/usb/dvb-usb/dvb-usb-init.c:184 [inline]
[<ffffffff844af012>] dvb_usb_device_init.cold+0x4e5/0x79e drivers/media/usb/dvb-usb/dvb-usb-init.c:308
[<ffffffff830db21d>] dib0700_probe+0x8d/0x1b0 drivers/media/usb/dvb-usb/dib0700_core.c:883
[<ffffffff82d3fdc7>] usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396
[<ffffffff8274ab37>] call_driver_probe drivers/base/dd.c:542 [inline]
[<ffffffff8274ab37>] really_probe.part.0+0xe7/0x310 drivers/base/dd.c:621
[<ffffffff8274ae6c>] really_probe drivers/base/dd.c:583 [inline]
[<ffffffff8274ae6c>] __driver_probe_device+0x10c/0x1e0 drivers/base/dd.c:752
[<ffffffff8274af6a>] driver_probe_device+0x2a/0x120 drivers/base/dd.c:782
[<ffffffff8274b786>] __device_attach_driver+0xf6/0x140 drivers/base/dd.c:899
[<ffffffff82747c87>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:427
[<ffffffff8274b352>] __device_attach+0x122/0x260 drivers/base/dd.c:970
[<ffffffff827498f6>] bus_probe_device+0xc6/0xe0 drivers/base/bus.c:487
[<ffffffff82745cdb>] device_add+0x5fb/0xdf0 drivers/base/core.c:3405
[<ffffffff82d3d202>] usb_set_configuration+0x8f2/0xb80 drivers/usb/core/message.c:2170
[<ffffffff82d4dbfc>] usb_generic_driver_probe+0x8c/0xc0 drivers/usb/core/generic.c:238
[<ffffffff82d3f49c>] usb_probe_device+0x5c/0x140 drivers/usb/core/driver.c:293
[<ffffffff8274ab37>] call_driver_probe drivers/base/dd.c:542 [inline]
[<ffffffff8274ab37>] really_probe.part.0+0xe7/0x310 drivers/base/dd.c:621
[<ffffffff8274ae6c>] really_probe drivers/base/dd.c:583 [inline]
[<ffffffff8274ae6c>] __driver_probe_device+0x10c/0x1e0 drivers/base/dd.c:752--- drivers/media/usb/dvb-usb/dvb-usb-init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/usb/dvb-usb/dvb-usb-init.c +3 -1
@@ -81,7 +81,7 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d, short *adapter_nrs) ret =dvb_usb_adapter_stream_init (adap);if (ret) -return ret; + goto stream_init_err; ret =dvb_usb_adapter_dvb_init (adap, adapter_nrs);if (ret)
@@ -114,6 +114,8 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d, short *adapter_nrs)dvb_usb_adapter_dvb_exit (adap); dvb_init_err:dvb_usb_adapter_stream_exit (adap); +stream_init_err: +kfree (adap->priv);return ret; }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 51/73 media: dvbdev: adopts refcnt to avoid UAF
In reply to Sasha LevinFrom: Lin Ma <[email protected]>
[ Upstream commit 0fc044b2b5e2d05a1fa1fb0d7f270367a7855d79 ]
dvb_unregister_device() is known that prone to use-after-free. That is, the cleanup from dvb_unregister_device() releases the dvb_device even if there are pointers stored in file->private_data still refer to it.
This patch adds a reference counter into struct dvb_device and delays its deallocation until no pointer refers to the object.
--- drivers/media/dvb-core/dvb_ca_en50221.c | 2 +- drivers/media/dvb-core/dvb_frontend.c | 2 +- drivers/media/dvb-core/dvbdev.c | 32 +++++++++++++++++++------ include/media/dvbdev.h | 31 +++++++++++++----------- 4 files changed, 44 insertions(+), 23 deletions(-)
drivers/media/dvb-core/dvb_ca_en50221.c +1 -1
@@ -157,7 +157,7 @@ static void dvb_ca_private_free(struct dvb_ca_private *ca) {unsigned int i; -dvb_free_device (ca->dvbdev); +dvb_device_put (ca->dvbdev);for (i =0 ; i < ca->slot_count; i++)vfree (ca->slot_info[i].rx_buffer.data);
drivers/media/dvb-core/dvb_frontend.c +1 -1
@@ -136,7 +136,7 @@ static void __dvb_frontend_free(struct dvb_frontend *fe)struct dvb_frontend_private *fepriv = fe->frontend_priv;if (fepriv) -dvb_free_device (fepriv->dvbdev); +dvb_device_put (fepriv->dvbdev);dvb_frontend_invoke_release (fe, fe->ops.release);
drivers/media/dvb-core/dvbdev.c +25 -7
@@ -97,7 +97,7 @@ static int dvb_device_open(struct inode *inode, struct file *file) new_fops =fops_get (dvbdev->fops);if (!new_fops) goto fail; - file->private_data = dvbdev; + file->private_data =dvb_device_get (dvbdev);replace_fops (file, new_fops);if (file->f_op->open) err = file->f_op->open (inode, file);
@@ -161,6 +161,9 @@ int dvb_generic_release(struct inode *inode, struct file *file) } dvbdev->users++; + +dvb_device_put (dvbdev); +return 0 ; }EXPORT_SYMBOL (dvb_generic_release);
@@ -477,6 +480,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,return -ENOMEM ; } +kref_init (&dvbdev->ref);memcpy (dvbdev, template,sizeof (struct dvb_device )); dvbdev->type = type; dvbdev->id = id;
@@ -508,7 +512,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,#endif dvbdev->minor = minor; - dvb_minors[minor] = dvbdev; + dvb_minors[minor] =dvb_device_get (dvbdev);up_write (&minor_rwsem); ret =dvb_register_media_device (dvbdev, type, minor, demux_sink_pads);
@@ -553,6 +557,7 @@ void dvb_remove_device(struct dvb_device *dvbdev)down_write (&minor_rwsem); dvb_minors[dvbdev->minor] =NULL ; +dvb_device_put (dvbdev);up_write (&minor_rwsem);dvb_media_device_free (dvbdev);
@@ -564,21 +569,34 @@ void dvb_remove_device(struct dvb_device *dvbdev)EXPORT_SYMBOL (dvb_remove_device); -void dvb_free_device (struct dvb_device *dvbdev) +static void dvb_free_device (struct kref *ref) { -if (!dvbdev) -return ; + struct dvb_device *dvbdev = container_of(ref, struct dvb_device, ref);kfree (dvbdev->fops);kfree (dvbdev); } -EXPORT_SYMBOL (dvb_free_device); + + +struct dvb_device *dvb_device_get (struct dvb_device *dvbdev) +{ +kref_get (&dvbdev->ref); +return dvbdev; +} +EXPORT_SYMBOL (dvb_device_get); + + +void dvb_device_put (struct dvb_device *dvbdev) +{ +if (dvbdev) +kref_put (&dvbdev->ref, dvb_free_device); +}void dvb_unregister_device (struct dvb_device *dvbdev) {dvb_remove_device (dvbdev); -dvb_free_device (dvbdev); +dvb_device_put (dvbdev); }EXPORT_SYMBOL (dvb_unregister_device);
include/media/dvbdev.h +17 -14
@@ -156,6 +156,7 @@ struct dvb_adapter {*/ struct dvb_device {struct list_head list_head; +struct kref ref;const struct file_operations *fops;struct dvb_adapter *adapter;enum dvb_device_type type;
@@ -187,6 +188,20 @@ struct dvb_device {void *priv; }; +/** +* dvb_device_get - Increase dvb_device reference +* +* @dvbdev: pointer to struct dvb_device +*/ +struct dvb_device *dvb_device_get (struct dvb_device *dvbdev); + +/** +* dvb_device_get - Decrease dvb_device reference +* +* @dvbdev: pointer to struct dvb_device +*/ +void dvb_device_put (struct dvb_device *dvbdev); +/** * dvb_register_adapter - Registers a new DVB adapter *
@@ -231,29 +246,17 @@ int dvb_register_device(struct dvb_adapter *adap,/** * dvb_remove_device - Remove a registered DVB device * -* This does not free memory. To do that, call dvb_free_device(). +* This does not free memory. dvb_free_device() will do that when +* reference counter is empty * * @dvbdev: pointer to struct dvb_device */ void dvb_remove_device (struct dvb_device *dvbdev); -/** -* dvb_free_device - Free memory occupied by a DVB device. -* -* Call dvb_unregister_device() before calling this function. -* -* @dvbdev: pointer to struct dvb_device -*/ -void dvb_free_device (struct dvb_device *dvbdev);/** * dvb_unregister_device - Unregisters a DVB device * -* This is a combination of dvb_remove_device() and dvb_free_device(). -* Using this function is usually a mistake, and is often an indicator -* for a use-after-free bug (when a userspace process keeps a file -* handle to a detached device). -* * @dvbdev: pointer to struct dvb_device */ void dvb_unregister_device (struct dvb_device *dvbdev);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 54/73 blk-mq: fix possible memleak when register 'hctx' failed
In reply to Sasha LevinFrom: Ye Bin <[email protected]>
[ Upstream commit 4b7a21c57b14fbcd0e1729150189e5933f5088e9 ]
There's issue as follows when do fault injection test:
unreferenced object 0xffff888132a9f400 (size 512):
comm "insmod", pid 308021, jiffies 4324277909 (age 509.733s) hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 08 f4 a9 32 81 88 ff ff ...........2....
08 f4 a9 32 81 88 ff ff 00 00 00 00 00 00 00 00 ...2............
backtrace:
[<00000000e8952bb4>] kmalloc_node_trace+0x22/0xa0
[<00000000f9980e0f>] blk_mq_alloc_and_init_hctx+0x3f1/0x7e0
[<000000002e719efa>] blk_mq_realloc_hw_ctxs+0x1e6/0x230
[<000000004f1fda40>] blk_mq_init_allocated_queue+0x27e/0x910
[<00000000287123ec>] __blk_mq_alloc_disk+0x67/0xf0
[<00000000a2a34657>] 0xffffffffa2ad310f
[<00000000b173f718>] 0xffffffffa2af824a
[<0000000095a1dabb>] do_one_initcall+0x87/0x2a0
[<00000000f32fdf93>] do_init_module+0xdf/0x320
[<00000000cbe8541e>] load_module+0x3006/0x3390
[<0000000069ed1bdb>] __do_sys_finit_module+0x113/0x1b0
[<00000000a1a29ae8>] do_syscall_64+0x35/0x80
[<000000009cd878b0>] entry_SYSCALL_64_after_hwframe+0x46/0xb0Fault injection context as follows:
kobject_add
blk_mq_register_hctx
blk_mq_sysfs_register
blk_register_queue
device_add_disk
null_add_dev.part.0 [null_blk]
As 'blk_mq_register_hctx' may already add some objects when failed halfway, but there isn't do fallback, caller don't know which objects add failed. To solve above issue just do fallback when add objects failed halfway in 'blk_mq_register_hctx'.
--- block/blk-mq-sysfs.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
block/blk-mq-sysfs.c +9 -2
@@ -185,7 +185,7 @@ static int blk_mq_register_hctx(struct blk_mq_hw_ctx *hctx) {struct request_queue *q = hctx->queue;struct blk_mq_ctx *ctx; -int i, ret; +int i, j, ret;if (!hctx->nr_ctx)return 0 ;
@@ -197,9 +197,16 @@ static int blk_mq_register_hctx(struct blk_mq_hw_ctx *hctx)hctx_for_each_ctx (hctx, ctx, i) { ret =kobject_add (&ctx->kobj, &hctx->kobj,"cpu%u" , ctx->cpu);if (ret) -break ; + goto out; } +return 0 ; +out: +hctx_for_each_ctx (hctx, ctx, j) { +if (j < i) +kobject_del (&ctx->kobj); + } +kobject_del (&hctx->kobj);return ret; }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 59/73 regulator: core: fix use_count leakage when handling boot-on
In reply to Sasha LevinFrom: Rui Zhang <[email protected]>
[ Upstream commit 0591b14ce0398125439c759f889647369aa616a0 ]
I found a use_count leakage towards supply regulator of rdev with boot-on option.
┌───────────────────┐ ┌───────────────────┐ │ regulator_dev A │ │ regulator_dev B │ │ (boot-on) │ │ (boot-on) │ │ use_count=0 │◀──supply──│ use_count=1 │ │ │ │ │ └───────────────────┘ └───────────────────┘
In case of rdev(A) configured with `regulator-boot-on', the use_count of supplying regulator(B) will increment inside regulator_enable(rdev->supply).
Thus, B will acts like always-on, and further balanced regulator_enable/disable cannot actually disable it anymore.
However, B was also configured with `regulator-boot-on', we wish it could be disabled afterwards.
--- drivers/regulator/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/regulator/core.c +7 -1
@@ -1578,7 +1578,13 @@ static int set_machine_constraints(struct regulator_dev *rdev)if (rdev->supply_name && !rdev->supply)return -EPROBE_DEFER ; -if (rdev->supply) { +/* If supplying regulator has already been enabled, +* it's not intended to have use_count increment +* when rdev is only boot-on. +*/ +if (rdev->supply && + (rdev->constraints->always_on || + !regulator_is_enabled (rdev->supply))) { ret =regulator_enable (rdev->supply);if (ret <0 ) {_regulator_put (rdev->supply);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 58/73 libbpf: Avoid enum forward-declarations in public API in C++ mode
In reply to Sasha LevinFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit b42693415b86f608049cf1b4870adc1dc65e58b0 ]
C++ enum forward declarations are fundamentally not compatible with pure C enum definitions, and so libbpf's use of enum bpf_stats_type; forward declaration in libbpf/bpf.h public API header is causing C++ compilation issues.
More details can be found in [0], but it comes down to C++ supporting enum forward declaration only with explicitly specified backing type:
enum bpf_stats_type: int;
In C (and I believe it's a GCC extension also), such forward declaration is simply:
enum bpf_stats_type;
Further, in Linux UAPI this enum is defined in pure C way:
enum bpf_stats_type { BPF_STATS_RUN_TIME = 0; }
And even though in both cases backing type is int, which can be confirmed by looking at DWARF information, for C++ compiler actual enum definition and forward declaration are incompatible.
To eliminate this problem, for C++ mode define input argument as int, which makes enum unnecessary in libbpf public header. This solves the issue and as demonstrated by next patch doesn't cause any unwanted compiler warnings, at least with default warnings setting.
[0] https://stackoverflow.com/questions/42766839/c11-enum-forward-causes-underlying-type-mismatch
[1] Closes: https://github.com/libbpf/libbpf/issues/249
--- tools/lib/bpf/bpf.h | 7 +++++++ 1 file changed, 7 insertions(+)
tools/lib/bpf/bpf.h +7 -0
@@ -393,8 +393,15 @@ LIBBPF_API int bpf_task_fd_query(int pid, int fd, __u32 flags, char *buf, __u32 *buf_len, __u32 *prog_id, __u32 *fd_type, __u64 *probe_offset, __u64 *probe_addr); +#ifdef __cplusplus +/* forward-declaring enums in C++ isn't compatible with pure C enums, so +* instead define bpf_enable_stats() as accepting int as an input +*/ +LIBBPF_API int bpf_enable_stats(int type); +#else enum bpf_stats_type ;/* defined in up-to-date linux/bpf.h */ LIBBPF_API int bpf_enable_stats(enum bpf_stats_type type); +#endif struct bpf_prog_bind_opts {size_t sz;/* size of this struct for forward/backward compatibility */
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 60/73 net: dpaa2: publish MAC stringset to ethtool -S even if MAC is missing
In reply to Sasha LevinFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 29811d6e19d795efcf26644b66c4152abbac35a6 ]
DPNIs and DPSW objects can connect and disconnect at runtime from DPMAC objects on the same fsl-mc bus. The DPMAC object also holds "ethtool -S" unstructured counters. Those counters are only shown for the entity owning the netdev (DPNI, DPSW) if it's connected to a DPMAC.
The ethtool stringset code path is split into multiple callbacks, but currently, connecting and disconnecting the DPMAC takes the rtnl_lock(). This blocks the entire ethtool code path from running, see ethnl_default_doit() -> rtnl_lock() -> ops->prepare_data() -> strset_prepare_data().
This is going to be a problem if we are going to no longer require rtnl_lock() when connecting/disconnecting the DPMAC, because the DPMAC could appear between ops->get_sset_count() and ops->get_strings(). If it appears out of the blue, we will provide a stringset into an array that was dimensioned thinking the DPMAC wouldn't be there => array accessed out of bounds.
There isn't really a good way to work around that, and I don't want to put too much pressure on the ethtool framework by playing locking games. Just make the DPMAC counters be always available. They'll be zeroes if the DPNI or DPSW isn't connected to a DPMAC.
--- drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c | 12 +++--------- .../ethernet/freescale/dpaa2/dpaa2-switch-ethtool.c | 11 ++--------- 2 files changed, 5 insertions(+), 18 deletions(-)
drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c +3 -9
@@ -186,7 +186,6 @@ static int dpaa2_eth_set_pauseparam(struct net_device *net_dev,static void dpaa2_eth_get_strings (struct net_device *netdev,u32 stringset,u8 *data) { -struct dpaa2_eth_priv *priv =netdev_priv (netdev);u8 *p = data;int i;
@@ -200,22 +199,17 @@ static void dpaa2_eth_get_strings(struct net_device *netdev, u32 stringset,strscpy (p, dpaa2_ethtool_extras[i],ETH_GSTRING_LEN ); p +=ETH_GSTRING_LEN ; } -if (dpaa2_eth_has_mac (priv)) -dpaa2_mac_get_strings (p); +dpaa2_mac_get_strings (p);break ; } }static int dpaa2_eth_get_sset_count (struct net_device *net_dev,int sset) { -int num_ss_stats =DPAA2_ETH_NUM_STATS +DPAA2_ETH_NUM_EXTRA_STATS ; -struct dpaa2_eth_priv *priv =netdev_priv (net_dev); -switch (sset) {case ETH_SS_STATS :/* ethtool_get_stats(), ethtool_get_drvinfo() */ -if (dpaa2_eth_has_mac (priv)) - num_ss_stats +=dpaa2_mac_get_sset_count (); -return num_ss_stats; +return DPAA2_ETH_NUM_STATS +DPAA2_ETH_NUM_EXTRA_STATS + +dpaa2_mac_get_sset_count ();default :return -EOPNOTSUPP ; }
drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-ethtool.c +2 -9
@@ -145,14 +145,9 @@ dpaa2_switch_set_link_ksettings(struct net_device *netdev,static int dpaa2_switch_ethtool_get_sset_count (struct net_device *netdev,int sset) { -struct ethsw_port_priv *port_priv =netdev_priv (netdev); -int num_ss_stats =DPAA2_SWITCH_NUM_COUNTERS ; -switch (sset) {case ETH_SS_STATS : -if (port_priv->mac) - num_ss_stats +=dpaa2_mac_get_sset_count (); -return num_ss_stats; +return DPAA2_SWITCH_NUM_COUNTERS +dpaa2_mac_get_sset_count ();default :return -EOPNOTSUPP ; }
@@ -161,7 +156,6 @@ dpaa2_switch_ethtool_get_sset_count(struct net_device *netdev, int sset)static void dpaa2_switch_ethtool_get_strings (struct net_device *netdev,u32 stringset,u8 *data) { -struct ethsw_port_priv *port_priv =netdev_priv (netdev);u8 *p = data;int i;
@@ -172,8 +166,7 @@ static void dpaa2_switch_ethtool_get_strings(struct net_device *netdev, ETH_GSTRING_LEN); p +=ETH_GSTRING_LEN ; } -if (port_priv->mac) -dpaa2_mac_get_strings (p); +dpaa2_mac_get_strings (p);break ; } }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 62/73 hwmon: (nct6775) add ASUS CROSSHAIR VIII/TUF/ProArt B550M
In reply to Sasha LevinFrom: Denis Pauk <[email protected]>
[ Upstream commit 1864069c695d475e0ce98a335c62274b81be57b4 ]
Boards such as
* ProArt B550-CREATOR
* ProArt Z490-CREATOR 10G
* ROG CROSSHAIR VIII EXTREME
* ROG CROSSHAIR VIII HERO (WI-FI)
* TUF GAMING B550M-E
* TUF GAMING B550M-E (WI-FI)
* TUF GAMING B550M-PLUS WIFI II
have got a nct6775 chip, but by default there's no use of it because of resource conflict with WMI method.
This commit adds such boards to the WMI monitoring list.
--- drivers/hwmon/nct6775-platform.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/hwmon/nct6775-platform.c +7 -0
@@ -1043,7 +1043,9 @@ static struct platform_device *pdev[2];static const char *const asus_wmi_boards[] = {"PRO H410T" , +"ProArt B550-CREATOR" ,"ProArt X570-CREATOR WIFI" , +"ProArt Z490-CREATOR 10G" ,"Pro B550M-C" ,"Pro WS X570-ACE" ,"PRIME B360-PLUS" ,
@@ -1055,8 +1057,10 @@ static const char * const asus_wmi_boards[] = {"PRIME X570-P" ,"PRIME X570-PRO" ,"ROG CROSSHAIR VIII DARK HERO" , +"ROG CROSSHAIR VIII EXTREME" ,"ROG CROSSHAIR VIII FORMULA" ,"ROG CROSSHAIR VIII HERO" , +"ROG CROSSHAIR VIII HERO (WI-FI)" ,"ROG CROSSHAIR VIII IMPACT" ,"ROG STRIX B550-A GAMING" , "ROG STRIX B550-E GAMING",
@@ -1080,8 +1084,11 @@ static const char * const asus_wmi_boards[] = {"ROG STRIX Z490-G GAMING (WI-FI)" ,"ROG STRIX Z490-H GAMING" ,"ROG STRIX Z490-I GAMING" , +"TUF GAMING B550M-E" , +"TUF GAMING B550M-E (WI-FI)" ,"TUF GAMING B550M-PLUS" ,"TUF GAMING B550M-PLUS (WI-FI)" , +"TUF GAMING B550M-PLUS WIFI II" ,"TUF GAMING B550-PLUS" ,"TUF GAMING B550-PLUS WIFI II" , "TUF GAMING B550-PRO",
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 64/73 nfs: fix possible null-ptr-deref when parsing param
In reply to Sasha LevinFrom: Hawkins Jiawei <[email protected]>
[ Upstream commit 5559405df652008e56eee88872126fe4c451da67 ]
According to commit "vfs: parse: deal with zero length string value", kernel will set the param->string to null pointer in vfs_parse_fs_string() if fs string has zero length.
Yet the problem is that, nfs_fs_context_parse_param() will dereferences the param->string, without checking whether it is a null pointer, which may trigger a null-ptr-deref bug.
This patch solves it by adding sanity check on param->string in nfs_fs_context_parse_param().
--- fs/nfs/fs_context.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/nfs/fs_context.c +6 -0
@@ -684,6 +684,8 @@ static int nfs_fs_context_parse_param(struct fs_context *fc,return ret;break ;case Opt_vers: +if (!param->string) + goto out_invalid_value;trace_nfs_mount_assign (param->key, param->string); ret =nfs_parse_version_string (fc, param->string);if (ret <0 )
@@ -696,6 +698,8 @@ static int nfs_fs_context_parse_param(struct fs_context *fc,break ;case Opt_proto: +if (!param->string) + goto out_invalid_value;trace_nfs_mount_assign (param->key, param->string); protofamily =AF_INET ;switch (lookup_constant (nfs_xprt_protocol_tokens, param->string,-1 )) {
@@ -732,6 +736,8 @@ static int nfs_fs_context_parse_param(struct fs_context *fc,break ;case Opt_mountproto: +if (!param->string) + goto out_invalid_value;trace_nfs_mount_assign (param->key, param->string); mountfamily =AF_INET ;switch (lookup_constant (nfs_xprt_protocol_tokens, param->string,-1 )) {
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 63/73 selftests/bpf: Fix conflicts with built-in functions in bpf_iter_ksym
In reply to Sasha LevinFrom: James Hilliard <[email protected]>
[ Upstream commit ab0350c743d5c93fd88742f02b3dff12168ab435 ]
Both tolower and toupper are built in c functions, we should not redefine them as this can result in a build error.
Fixes the following errors:progs/bpf_iter_ksym.c:10:20: error: conflicting types for built-in function 'tolower'; expected 'int(int)' [-Werror=builtin-declaration-mismatch]
10 | static inline char tolower(char c)
| ^~~~~~~
progs/bpf_iter_ksym.c:5:1: note: 'tolower' is declared in header '<ctype.h>'
4 | #include <bpf/bpf_helpers.h>
+++ |+#include <ctype.h>
5 |
progs/bpf_iter_ksym.c:17:20: error: conflicting types for built-in function 'toupper'; expected 'int(int)' [-Werror=builtin-declaration-mismatch]
17 | static inline char toupper(char c)
| ^~~~~~~progs/bpf_iter_ksym.c:17:20: note: 'toupper' is declared in header '<ctype.h>'
See background on this sort of issue:
https://stackoverflow.com/a/20582607
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12213
(C99, 7.1.3p1) "All identifiers with external linkage in any of the following subclauses (including the future library directions) are always reserved for use as identifiers with external linkage."
This is documented behavior in GCC:
https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-std-2
--- tools/testing/selftests/bpf/progs/bpf_iter_ksym.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/progs/bpf_iter_ksym.c +3 -3
@@ -7,14 +7,14 @@ char _license[] SEC("license") = "GPL";unsigned long last_sym_value =0 ; -static inline char tolower (char c) +static inline char to_lower (char c) {if (c >='A' && c <='Z' ) c += ('a' -'A' );return c; } -static inline char toupper (char c) +static inline char to_upper (char c) {if (c >='a' && c <='z' ) c -= ('a' -'A' );
@@ -54,7 +54,7 @@ int dump_ksym(struct bpf_iter__ksym *ctx) type = iter->type;if (iter->module_name[0 ]) { - type = iter->exported ?toupper (type) :tolower (type); + type = iter->exported ?to_upper (type) :to_lower (type);BPF_SEQ_PRINTF (seq,"0x%llx %c %s [ %s ] " , value, type, iter->name, iter->module_name); }else {
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 65/73 mmc: f-sdh30: Add quirks for broken timeout clock capability
In reply to Sasha LevinFrom: Kunihiko Hayashi <[email protected]>
[ Upstream commit aae9d3a440736691b3c1cb09ae2c32c4f1ee2e67 ]
There is a case where the timeout clock is not supplied to the capability. Add a quirk for that.
--- drivers/mmc/host/sdhci_f_sdh30.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mmc/host/sdhci_f_sdh30.c +3 -0
@@ -168,6 +168,9 @@ static int sdhci_f_sdh30_probe(struct platform_device *pdev)if (reg &SDHCI_CAN_DO_8BIT ) priv->vendor_hs200 =F_SDH30_EMMC_HS200 ; +if (!(reg &SDHCI_TIMEOUT_CLK_MASK )) + host->quirks |=SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK ; + ret =sdhci_add_host (host);if (ret) goto err_add_host;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 66/73 mmc: renesas_sdhi: add quirk for broken register layout
In reply to Sasha LevinFrom: Wolfram Sang <[email protected]>
[ Upstream commit ec9e80ae1719de541c719116a1ca0a0c70e9240c ]
Some early Gen3 SoCs have the DTRANEND1 bit at a different location than all later SoCs. Because we need the bit soon, add a quirk so we know which bit to use.
--- drivers/mmc/host/renesas_sdhi.h | 1 + drivers/mmc/host/renesas_sdhi_internal_dmac.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/mmc/host/renesas_sdhi.h +1 -0
@@ -44,6 +44,7 @@ struct renesas_sdhi_quirks {bool fixed_addr_mode;bool dma_one_rx_only;bool manual_tap_correction; +bool old_info1_layout;u32 hs400_bad_taps;const u8 (*hs400_calib_table)[SDHI_CALIB_TABLE_MAX ]; };
drivers/mmc/host/renesas_sdhi_internal_dmac.c +3 -1
@@ -49,7 +49,8 @@/* DM_CM_INFO1 and DM_CM_INFO1_MASK */ #define INFO1_CLEAR 0#define INFO1_MASK_CLEAR GENMASK_ULL(31, 0) -#define INFO1_DTRANEND1 BIT(17) +#define INFO1_DTRANEND1 BIT(20) +#define INFO1_DTRANEND1_OLD BIT(17)#define INFO1_DTRANEND0 BIT(16)/* DM_CM_INFO2 and DM_CM_INFO2_MASK */
@@ -165,6 +166,7 @@ static const struct renesas_sdhi_quirks sdhi_quirks_4tap_nohs400_one_rx = { .hs400_disabled = true, .hs400_4taps = true, .dma_one_rx_only = true, + .old_info1_layout = true, };static const struct renesas_sdhi_quirks sdhi_quirks_4tap = {
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 67/73 mmc: renesas_sdhi: better reset from HS400 mode
In reply to Sasha LevinFrom: Wolfram Sang <[email protected]>
[ Upstream commit 0da69dd2155019ed4c444ede0e79ce7a4a6af627 ]
Up to now, HS400 adjustment mode was only disabled on soft reset when a calibration table was in use. It is safer, though, to disable it as soon as the instance has an adjustment related quirk set, i.e. bad taps or a calibration table.
--- drivers/mmc/host/renesas_sdhi_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/renesas_sdhi_core.c +1 -1
@@ -546,7 +546,7 @@ static void renesas_sdhi_reset_hs400_mode(struct tmio_mmc_host *host, SH_MOBILE_SDHI_SCC_TMPPORT2_HS400OSEL) & sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_TMPPORT2)); -if (priv->adjust_hs400_calib_table) +if (priv->quirks && (priv->quirks->hs400_calib_table || priv->quirks->hs400_bad_taps))renesas_sdhi_adjust_hs400_mode_disable (host); sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, CLK_CTL_SCLKEN |
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 68/73 media: si470x: Fix use-after-free in si470x_int_in_callback()
In reply to Sasha LevinFrom: Shigeru Yoshida <[email protected]>
[ Upstream commit 7d21e0b1b41b21d628bf2afce777727bd4479aa5 ]
syzbot reported use-after-free in si470x_int_in_callback() [1]. This indicates that urb->context, which contains struct si470x_device object, is freed when si470x_int_in_callback() is called.
The cause of this issue is that si470x_int_in_callback() is called for freed urb.
si470x_usb_driver_probe() calls si470x_start_usb(), which then calls usb_submit_urb() and si470x_start(). If si470x_start_usb() fails, si470x_usb_driver_probe() doesn't kill urb, but it just frees struct si470x_device object, as depicted below:
si470x_usb_driver_probe()
...
si470x_start_usb()
...
usb_submit_urb()
retval = si470x_start()
return retval
if (retval < 0)
free struct si470x_device object, but don't kill urbThis patch fixes this issue by killing urb when si470x_start_usb() fails and urb is submitted. If si470x_start_usb() fails and urb is not submitted, i.e. submitting usb fails, it just frees struct si470x_device object.
--- drivers/media/radio/si470x/radio-si470x-usb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/radio/si470x/radio-si470x-usb.c +3 -1
@@ -727,8 +727,10 @@ static int si470x_usb_driver_probe(struct usb_interface *intf,/* start radio */ retval =si470x_start_usb (radio); -if (retval <0 ) +if (retval <0 && !radio->int_in_running) goto err_buf; +else if (retval <0 )/* in case of radio->int_in_running == 1 */ + goto err_all;/* set initial frequency */ si470x_set_freq (radio,87.5 *FREQ_MUL );/* available in all regions */
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 69/73 clk: st: Fix memory leak in st_of_quadfs_setup()
In reply to Sasha LevinFrom: Xiu Jianfeng <[email protected]>
[ Upstream commit cfd3ffb36f0d566846163118651d868e607300ba ]
If st_clk_register_quadfs_pll() fails, @lock should be freed before goto @err_exit, otherwise will cause meory leak issue, fix it.
--- drivers/clk/st/clkgen-fsyn.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/clk/st/clkgen-fsyn.c +3 -2
@@ -1020,9 +1020,10 @@ static void __init st_of_quadfs_setup(struct device_node *np, clk =st_clk_register_quadfs_pll (pll_name, clk_parent_name, datac->data, reg, lock); -if (IS_ERR (clk)) +if (IS_ERR (clk)) { +kfree (lock); goto err_exit; -else + }else pr_debug("%s: parent %s rate %u\n", __clk_get_name(clk), __clk_get_name(clk_get_parent(clk)),
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 71/73 Bluetooth: hci_bcm: Add CYW4373A0 support
In reply to Sasha LevinFrom: Marek Vasut <[email protected]>
[ Upstream commit 02d056a3404e20245a69dcb4022a0930085fc5ec ]
CYW4373A0 is a Wi-Fi + Bluetooth combo device from Cypress. This chip is present e.g. on muRata 2AE module.
This chip has additional quirk where the HCI command 0xfc45, used on older chips to switch UART clock from 24 MHz to 48 MHz, to support baudrates over 3 Mbdps, is no longer recognized by this newer chip. This newer chip can configure the 4 Mbdps baudrate without the need to issue HCI command 0xfc45, so add flag to indicate this and do not issue the command on this chip to avoid failure to set 4 Mbdps baud rate.
It is not clear whether there is a way to determine which chip does and which chip does not support the HCI command 0xfc45, other than trial and error.
--- drivers/bluetooth/hci_bcm.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/bluetooth/hci_bcm.c +12 -1
@@ -53,11 +53,13 @@* struct bcm_device_data - device specific data * @no_early_set_baudrate: Disallow set baudrate before driver setup() * @drive_rts_on_open: drive RTS signal on ->open() when platform requires it +* @no_uart_clock_set: UART clock set command for >3Mbps mode is unavailable * @max_autobaud_speed: max baudrate supported by device in autobaud mode */ struct bcm_device_data {bool no_early_set_baudrate;bool drive_rts_on_open; +bool no_uart_clock_set;u32 max_autobaud_speed; };
@@ -100,6 +102,7 @@ struct bcm_device_data {* @is_suspended: whether flow control is currently disabled * @no_early_set_baudrate: don't set_baudrate before setup() * @drive_rts_on_open: drive RTS signal on ->open() when platform requires it +* @no_uart_clock_set: UART clock set command for >3Mbps mode is unavailable * @pcm_int_params: keep the initial PCM configuration * @use_autobaud_mode: start Bluetooth device in autobaud mode * @max_autobaud_speed: max baudrate supported by device in autobaud mode
@@ -140,6 +143,7 @@ struct bcm_device {#endif bool no_early_set_baudrate;bool drive_rts_on_open; +bool no_uart_clock_set;bool use_autobaud_mode;u8 pcm_int_params[5 ];u32 max_autobaud_speed;
@@ -172,10 +176,11 @@ static inline void host_set_baudrate(struct hci_uart *hu, unsigned int speed)static int bcm_set_baudrate (struct hci_uart *hu,unsigned int speed) {struct hci_dev *hdev = hu->hdev; +struct bcm_data *bcm = hu->priv;struct sk_buff *skb;struct bcm_update_uart_baud_rate param; -if (speed >3000000 ) { +if (speed >3000000 && !bcm->dev->no_uart_clock_set) {struct bcm_write_uart_clock_setting clock; clock.type =BCM_UART_CLOCK_48MHZ ;
@@ -1529,6 +1534,7 @@ static int bcm_serdev_probe(struct serdev_device *serdev) bcmdev->max_autobaud_speed = data->max_autobaud_speed; bcmdev->no_early_set_baudrate = data->no_early_set_baudrate; bcmdev->drive_rts_on_open = data->drive_rts_on_open; + bcmdev->no_uart_clock_set = data->no_uart_clock_set; }return hci_uart_register_device (&bcmdev->serdev_hu, &bcm_proto);
@@ -1550,6 +1556,10 @@ static struct bcm_device_data bcm43438_device_data = { .drive_rts_on_open = true, }; +static struct bcm_device_data cyw4373a0_device_data = { + .no_uart_clock_set = true, +}; +static struct bcm_device_data cyw55572_device_data = { .max_autobaud_speed =921600 , };
@@ -1566,6 +1576,7 @@ static const struct of_device_id bcm_bluetooth_of_match[] = { { .compatible = "brcm,bcm4349-bt", .data = &bcm43438_device_data }, { .compatible = "brcm,bcm43540-bt", .data = &bcm4354_device_data }, { .compatible = "brcm,bcm4335a0" }, + { .compatible = "cypress,cyw4373a0-bt", .data = &cyw4373a0_device_data }, { .compatible = "infineon,cyw55572-bt", .data = &cyw55572_device_data }, { }, };
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 72/73 Bluetooth: Add quirk to disable extended scanning
In reply to Sasha LevinFrom: Sven Peter <[email protected]>
[ Upstream commit 392fca352c7a95e2828d49e7500e26d0c87ca265 ]
Broadcom 4377 controllers found in Apple x86 Macs with the T2 chip claim to support extended scanning when querying supported states,
< HCI Command: LE Read Supported St.. (0x08|0x001c) plen 0
Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 12
LE Read Supported States (0x08|0x001c) ncmd 1
Status: Success (0x00)
States: 0x000003ffffffffff[...]
LE Set Extended Scan Parameters (Octet 37 - Bit 5) LE Set Extended Scan Enable (Octet 37 - Bit 6)
[...]
, but then fail to actually implement the extended scanning:
< HCI Command: LE Set Extended Sca.. (0x08|0x0041) plen 8
Own address type: Random (0x01)
Filter policy: Accept all advertisement (0x00)
PHYs: 0x01
Entry 0: LE 1M
Type: Active (0x01)
Interval: 11.250 msec (0x0012)
Window: 11.250 msec (0x0012)Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 4
LE Set Extended Scan Parameters (0x08|0x0041) ncmd 1
Status: Unknown HCI Command (0x01)--- include/net/bluetooth/hci.h | 10 ++++++++++ include/net/bluetooth/hci_core.h | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-)
include/net/bluetooth/hci.h +10 -0
@@ -274,6 +274,16 @@ enum {* during the hdev->setup vendor callback. */ HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN , + +/* +* When this quirk is set, the HCI_OP_LE_SET_EXT_SCAN_ENABLE command is +* disabled. This is required for some Broadcom controllers which +* erroneously claim to support extended scanning. +* +* This quirk can be set before hci_register_dev is called or +* during the hdev->setup vendor callback. +*/ + HCI_QUIRK_BROKEN_EXT_SCAN, };/* HCI device flags */
include/net/bluetooth/hci_core.h +3 -1
@@ -1681,7 +1681,9 @@ void hci_conn_del_sysfs(struct hci_conn *conn);/* Use ext scanning if set ext scan param and ext scan enable is supported */ #define use_ext_scan (dev) (((dev)->commands[37] & 0x20) && \ - ((dev)->commands[37] & 0x40)) + ((dev)->commands[37] & 0x40) && \ + !test_bit(HCI_QUIRK_BROKEN_EXT_SCAN, &(dev)->quirks)) +/* Use ext create connection if command is supported */ #define use_ext_conn (dev) ((dev)->commands[37] & 0x80)
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 73/73 Bluetooth: Add quirk to disable MWS Transport Configuration
In reply to Sasha LevinFrom: Sven Peter <[email protected]>
[ Upstream commit ffcb0a445ec2d5753751437706aa0a7ea8351099 ]
Broadcom 4378/4387 controllers found in Apple Silicon Macs claim to support getting MWS Transport Layer Configuration,
< HCI Command: Read Local Supported... (0x04|0x0002) plen 0
Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 68
Read Local Supported Commands (0x04|0x0002) ncmd 1
Status: Success (0x00)[...]
Get MWS Transport Layer Configuration (Octet 30 - Bit 3)]
[...]
, but then don't actually allow the required command:
Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 15
Get MWS Transport Layer Configuration (0x05|0x000c) ncmd 1
Status: Command Disallowed (0x0c)
Number of transports: 0
Baud rate list: 0 entries
00 00 00 00 00 00 00 00 00 00--- include/net/bluetooth/hci.h | 10 ++++++++++ include/net/bluetooth/hci_core.h | 3 +++ net/bluetooth/hci_sync.c | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-)
include/net/bluetooth/hci.h +10 -0
@@ -284,6 +284,16 @@ enum {* during the hdev->setup vendor callback. */ HCI_QUIRK_BROKEN_EXT_SCAN , + +/* +* When this quirk is set, the HCI_OP_GET_MWS_TRANSPORT_CONFIG command is +* disabled. This is required for some Broadcom controllers which +* erroneously claim to support MWS Transport Layer Configuration. +* +* This quirk can be set before hci_register_dev is called or +* during the hdev->setup vendor callback. +*/ + HCI_QUIRK_BROKEN_MWS_TRANSPORT_CONFIG, };/* HCI device flags */
include/net/bluetooth/hci_core.h +3 -0
@@ -1711,6 +1711,9 @@ void hci_conn_del_sysfs(struct hci_conn *conn); ((dev)->le_features[3] & HCI_LE_CIS_PERIPHERAL)#define bis_capable (dev) ((dev)->le_features[3] & HCI_LE_ISO_BROADCASTER) +#define mws_transport_config_capable (dev) (((dev)->commands[30] & 0x08) && \ + (!test_bit(HCI_QUIRK_BROKEN_MWS_TRANSPORT_CONFIG, &(dev)->quirks))) +/* ----- HCI protocols ----- */ #define HCI_PROTO_DEFER 0x01
net/bluetooth/hci_sync.c +1 -1
@@ -3940,7 +3940,7 @@ static int hci_read_local_pairing_opts_sync(struct hci_dev *hdev)/* Get MWS transport configuration if the HCI command is supported */ static int hci_get_mws_transport_config_sync (struct hci_dev *hdev) { -if (!(hdev->commands[30 ] &0x08 )) +if (!mws_transport_config_capable (hdev))return 0 ; return __hci_cmd_sync_status(hdev, HCI_OP_GET_MWS_TRANSPORT_CONFIG,
Signature · 1 line
2.35.1
Re: [PATCH AUTOSEL 6.0 70/73] regulator: core: Use different devices for resource allocation and DT lookup
In reply to Sasha LevinOn Sun, Dec 18, 2022 at 11:07:38AM -0500, Sasha Levin wrote:
Hi,
Thanks, but there's one more case not considered.
It may cause a unexpected regulator shutdown by regulator core.
Here's the discussion link that reported from Marek Szyprowski.
https://lore.kernel.org/lkml/[email protected]/
I have post a patch to fix it.
You may need to cherry-pick the below patch also. 0debed5b117d ("regulator: core: Fix resolve supply lookup issue")
Best regards,
ChiYuan.
Quoted 159 lines
From: ChiYuan Huang <[email protected]>
[ Upstream commit
8f3cbcd6b440032ebc7f7d48a1689dcc70a4eb98]Following by the below discussion, there's the potential UAF issue between regulator and mfd.
https://lore.kernel.org/all/[email protected]/Quoted 1 line
From the analysis of Yingliang
CPU A |CPU B
mt6370_probe()|
devm_mfd_add_devices()||mt6370_regulator_probe() | regulator_register() | //allocate init_data and add it to devres | regulator_of_get_init_data() i2c_unregister_device() | device_del() | devres_release_all() | // init_data is freed | release_nodes() | | // using init_data causes UAF | regulator_register()It's common to use mfd core to create child device for the regulator. In order to do the DT lookup for init data, the child that registered the regulator would pass its parent as the parameter. And this causes init data resource allocated to its parent, not itself. The issue happen when parent device is going to release and regulator core is still doing some operation of init data constraint for the regulator of child device.
To fix it, this patch expand '
regulator_register' API to use the different devices for init data allocation and DT lookup.Reported-by Yang Yingliang <[email protected]>Signed-off-by ChiYuan Huang <[email protected]>Signed-off-by Mark Brown <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/platform/x86/intel/int3472/clk_and_regulator.c | 3 ++- drivers/regulator/core.c | 8 ++++---- drivers/regulator/devres.c | 2 +- drivers/regulator/of_regulator.c | 2 +- drivers/regulator/stm32-vrefbuf.c | 2 +- include/linux/regulator/driver.h | 3 ++- 6 files changed, 11 insertions(+), 9 deletions(-)drivers/platform/x86/intel/int3472/clk_and_regulator.c +2
-1@@ -185,7 +185,8 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, cfg.init_data = &init_data; cfg.ena_gpiod = int3472->regulator.gpio; - int3472->regulator.rdev =regulator_register (&int3472->regulator.rdesc, + int3472->regulator.rdev =regulator_register (int3472->dev, + &int3472->regulator.rdesc, &cfg);if (IS_ERR (int3472->regulator.rdev)) { ret =PTR_ERR (int3472->regulator.rdev);drivers/regulator/core.c +4
-4@@ -5386,6 +5386,7 @@ static struct regulator_coupler generic_regulator_coupler = {/** * regulator_register - register regulator +* @dev: the device that drive the regulator * @regulator_desc: regulator to register * @cfg: runtime configuration for regulator * @@ -5394,7 +5395,8 @@ static struct regulator_coupler generic_regulator_coupler = {* or an ERR_PTR() on error. */ struct regulator_dev * -regulator_register (const struct regulator_desc *regulator_desc, +regulator_register (struct device *dev, +const struct regulator_desc *regulator_desc,const struct regulator_config *cfg) {const struct regulator_init_data *init_data;@@ -5403,7 +5405,6 @@ regulator_register(const struct regulator_desc *regulator_desc,struct regulator_dev *rdev;bool dangling_cfg_gpiod = false;bool dangling_of_gpiod = false; -struct device *dev;int ret, i;if (cfg ==NULL )@@ -5415,8 +5416,7 @@ regulator_register(const struct regulator_desc *regulator_desc, goto rinse; } - dev = cfg->dev; -WARN_ON (!dev); +WARN_ON (!dev || !cfg->dev);if (regulator_desc->name ==NULL || regulator_desc->ops ==NULL ) { ret = -EINVAL ;drivers/regulator/devres.c +1
-1@@ -221,7 +221,7 @@ struct regulator_dev *devm_regulator_register(struct device *dev,if (!ptr)return ERR_PTR (-ENOMEM ); - rdev =regulator_register (regulator_desc, config); + rdev =regulator_register (dev, regulator_desc, config);if (!IS_ERR (rdev)) { *ptr = rdev;devres_add (dev, ptr);drivers/regulator/of_regulator.c +1
-1@@ -505,7 +505,7 @@ struct regulator_init_data *regulator_of_get_init_data(struct device *dev,struct device_node *child;struct regulator_init_data *init_data =NULL ; - child =regulator_of_get_init_node (dev, desc); + child =regulator_of_get_init_node (config->dev, desc);if (!child)return NULL ;drivers/regulator/stm32-vrefbuf.c +1
-1@@ -210,7 +210,7 @@ static int stm32_vrefbuf_probe(struct platform_device *pdev) pdev->dev.of_node, &stm32_vrefbuf_regu); - rdev =regulator_register (&stm32_vrefbuf_regu, &config); + rdev =regulator_register (&pdev->dev, &stm32_vrefbuf_regu, &config);if (IS_ERR (rdev)) { ret =PTR_ERR (rdev);dev_err (&pdev->dev,"register failed with error %d\n" , ret);include/linux/regulator/driver.h +2
-1@@ -687,7 +687,8 @@ static inline int regulator_err2notif(int err)struct regulator_dev * -regulator_register (const struct regulator_desc *regulator_desc, +regulator_register (struct device *dev, +const struct regulator_desc *regulator_desc,const struct regulator_config *config);struct regulator_dev * devm_regulator_register(struct device *dev,Signature · 1 line
2.35.1
Sasha Levin
maintainerRe: [PATCH AUTOSEL 6.0 70/73] regulator: core: Use different devices for resource allocation and DT lookup
Quoted 11 lines · ChiYuan Huang
On Sun, Dec 18, 2022 at 11:07:38AM -0500, Sasha Levin wrote:
Hi,
Thanks, but there's one more case not considered.
It may cause a unexpected regulator shutdown by regulator core.Here's the discussion link that reported from Marek Szyprowski.
https://lore.kernel.org/lkml/[email protected]/I have post a patch to fix it.
You may need to cherry-pick the below patch also.0debed5b117d("regulator: core: Fix resolve supply lookup issue")
I'll take it too, thanks!
Signature · 2 lines
Thanks, Sasha