drm/amd/display: Assign linear_pitch_alignment even for VM
Subsystems (19)
Sasha Levin
maintainerPATCH 1/47 drm/amd/display: Assign linear_pitch_alignment even for VM
From: Alvin Lee <[email protected]>
[ Upstream commit 984debc133efa05e62f5aa1a7a1dd8ca0ef041f4 ]
[Description]
Assign linear_pitch_alignment so we don't cause a divide by 0 error in VM environments
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/display/dc/core/dc.c +1 -0
@@ -1107,6 +1107,7 @@ struct dc *dc_create(const struct dc_init_data *init_params)return NULL ;if (init_params->dce_environment ==DCE_ENV_VIRTUAL_HW ) { + dc->caps.linear_pitch_alignment =64 ;if (!dc_construct_ctx (dc, init_params)) goto destruct_dc; }else {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 2/47 drm/amdgpu: fix overflowed array index read warning
From: Tim Huang <[email protected]>
[ Upstream commit ebbc2ada5c636a6a63d8316a3408753768f5aa9f ]
Clear overflowed array index read warning by cast operation.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +2 -1
@@ -367,8 +367,9 @@ static ssize_t amdgpu_debugfs_ring_read(struct file *f, char __user *buf, size_t size, loff_t *pos) { struct amdgpu_ring *ring = file_inode(f)->i_private; -int r, i;uint32_t value, result, early[3 ]; +loff_t i; +int r;if (*pos &3 || size &3 )return -EINVAL ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 3/47 drm/amdgpu/pm: Check the return value of smum_send_msg_to_smc
In reply to Sasha LevinFrom: Ma Jun <[email protected]>
[ Upstream commit 579f0c21baec9e7506b6bb3f60f0a9b6d07693b4 ]
Check the return value of smum_send_msg_to_smc, otherwise we might use an uninitialized variable "now"
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c +6 -2
@@ -1026,7 +1026,9 @@ static int smu10_print_clock_levels(struct pp_hwmgr *hwmgr,switch (type) {case PP_SCLK : -smum_send_msg_to_smc (hwmgr, PPSMC_MSG_GetGfxclkFrequency, &now); + ret =smum_send_msg_to_smc (hwmgr, PPSMC_MSG_GetGfxclkFrequency, &now); +if (ret) +return ret;/* driver only know min/max gfx_clk, Add level 1 for all other gfx clks */ if (now == data->gfx_max_freq_limit/100 )
@@ -1047,7 +1049,9 @@ static int smu10_print_clock_levels(struct pp_hwmgr *hwmgr, i == 2 ? "*" : "");break ;case PP_MCLK : -smum_send_msg_to_smc (hwmgr, PPSMC_MSG_GetFclkFrequency, &now); + ret =smum_send_msg_to_smc (hwmgr, PPSMC_MSG_GetFclkFrequency, &now); +if (ret) +return ret;for (i =0 ; i < mclk_table->count; i++) size += sprintf(buf + size, "%d: %uMhz %s\n",
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 4/47 drm/amd/pm: fix warning using uninitialized value of max_vid_step
In reply to Sasha LevinFrom: Jesse Zhang <[email protected]>
[ Upstream commit 17e3bea65cdc453695b2fe4ff26d25d17f5339e9 ]
Check the return of pp_atomfwctrl_get_Voltage_table_v4 as it may fail to initialize max_vid_step
V2: change the check condition (Tim Huang)
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c +4 -1
@@ -2575,8 +2575,11 @@ static int vega10_init_smc_table(struct pp_hwmgr *hwmgr) } } -pp_atomfwctrl_get_voltage_table_v4 (hwmgr,VOLTAGE_TYPE_VDDC , + result =pp_atomfwctrl_get_voltage_table_v4 (hwmgr,VOLTAGE_TYPE_VDDC ,VOLTAGE_OBJ_SVID2 , &voltage_table); +PP_ASSERT_WITH_CODE (!result, +"Failed to get voltage table!" , + return result); pp_table->MaxVidStep = voltage_table.max_vid_step; pp_table->GfxDpmVoltageMode =
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 5/47 drm/amd/pm: fix the Out-of-bounds read warning
In reply to Sasha LevinFrom: Jesse Zhang <[email protected]>
[ Upstream commit 12c6967428a099bbba9dfd247bb4322a984fcc0b ]
using index i - 1U may beyond element index for mc_data[] when i = 0.
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c +3 -2
@@ -73,8 +73,9 @@ static int atomctrl_retrieve_ac_timing( j++; }else if ((table->mc_reg_address[i].uc_pre_reg_data &LOW_NIBBLE_MASK ) ==DATA_EQU_PREV ) { - table->mc_reg_table_entry[num_ranges].mc_data[i] = - table->mc_reg_table_entry[num_ranges].mc_data[i-1 ]; +if (i) + table->mc_reg_table_entry[num_ranges].mc_data[i] = + table->mc_reg_table_entry[num_ranges].mc_data[i-1 ]; } } num_ranges++;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 6/47 drm/amdgpu: fix uninitialized scalar variable warning
In reply to Sasha LevinFrom: Tim Huang <[email protected]>
[ Upstream commit 9a5f15d2a29d06ce5bd50919da7221cda92afb69 ]
Clear warning that uses uninitialized value fw_size.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +2 -0
@@ -410,6 +410,8 @@ static void amdgpu_virt_add_bad_page(struct amdgpu_device *adev,uint64_t retired_page;uint32_t bp_idx, bp_cnt; +memset (&bp,0 ,sizeof (bp)); +if (bp_block_size) { bp_cnt = bp_block_size /sizeof (uint64_t );for (bp_idx =0 ; bp_idx < bp_cnt; bp_idx++) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 7/47 drm/amd/display: Check gpio_id before used as array index
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit 2a5626eeb3b5eec7a36886f9556113dd93ec8ed6 ]
[WHY & HOW]GPIO_ID_UNKNOWN (-1) is not a valid value for array index and therefore should be checked in advance.
This fixes 5 OVERRUN issues reported by Coverity.
--- drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c +11 -2
@@ -241,6 +241,9 @@ static bool is_pin_busy( enum gpio_id id, uint32_t en) { +if (id ==GPIO_ID_UNKNOWN ) +return false; +return service->busyness[id][en]; }
@@ -249,6 +252,9 @@ static void set_pin_busy( enum gpio_id id, uint32_t en) { +if (id ==GPIO_ID_UNKNOWN ) +return ; + service->busyness[id][en] = true; }
@@ -257,6 +263,9 @@ static void set_pin_free( enum gpio_id id, uint32_t en) { +if (id ==GPIO_ID_UNKNOWN ) +return ; + service->busyness[id][en] = false; }
@@ -265,7 +274,7 @@ enum gpio_result dal_gpio_service_lock( enum gpio_id id, uint32_t en) { -if (!service->busyness[id]) { +if (id !=GPIO_ID_UNKNOWN && !service->busyness[id]) {ASSERT_CRITICAL (false);return GPIO_RESULT_OPEN_FAILED ; }
@@ -279,7 +288,7 @@ enum gpio_result dal_gpio_service_unlock( enum gpio_id id, uint32_t en) { -if (!service->busyness[id]) { +if (id !=GPIO_ID_UNKNOWN && !service->busyness[id]) {ASSERT_CRITICAL (false);return GPIO_RESULT_OPEN_FAILED ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 8/47 drm/amd/display: Stop amdgpu_dm initialize when stream nums greater than 6
In reply to Sasha LevinFrom: Hersen Wu <[email protected]>
[ Upstream commit 84723eb6068c50610c5c0893980d230d7afa2105 ]
[Why]
Coverity reports OVERRUN warning. Should abort amdgpu_dm initialize.
[How]
Return failure to amdgpu_dm_init.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -1
@@ -4210,7 +4210,10 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev)/* There is one primary plane per CRTC */ primary_planes = dm->dc->caps.max_streams; -ASSERT (primary_planes <=AMDGPU_MAX_PLANES ); +if (primary_planes >AMDGPU_MAX_PLANES ) { +DRM_ERROR ("DM: Plane nums out of 6 planes\n" ); +return -EINVAL ; + }/* * Initialize primary planes, implicit planes for legacy IOCTLS.
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 9/47 drm/amd/display: Add array index check for hdcp ddc access
In reply to Sasha LevinFrom: Hersen Wu <[email protected]>
[ Upstream commit 4e70c0f5251c25885c31ee84a31f99a01f7cf50e ]
[Why]
Coverity reports OVERRUN warning. Do not check if array index valid.
[How]
Check msg_id valid and valid array index.
--- .../drm/amd/display/modules/hdcp/hdcp_ddc.c | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/modules/hdcp/hdcp_ddc.c +24 -4
@@ -156,11 +156,16 @@ static enum mod_hdcp_status read(struct mod_hdcp *hdcp,uint32_t cur_size =0 ;uint32_t data_offset =0 ; -if (msg_id ==MOD_HDCP_MESSAGE_ID_INVALID ) { +if (msg_id ==MOD_HDCP_MESSAGE_ID_INVALID || + msg_id >=MOD_HDCP_MESSAGE_ID_MAX )return MOD_HDCP_STATUS_DDC_FAILURE ; - }if (is_dp_hdcp (hdcp)) { +int num_dpcd_addrs =sizeof (hdcp_dpcd_addrs) / +sizeof (hdcp_dpcd_addrs[0 ]); +if (msg_id >= num_dpcd_addrs) +return MOD_HDCP_STATUS_DDC_FAILURE ; +while (buf_len >0 ) { cur_size =MIN (buf_len,HDCP_MAX_AUX_TRANSACTION_SIZE ); success = hdcp->config.ddc.funcs.read_dpcd(hdcp->config.ddc.handle,
@@ -175,6 +180,11 @@ static enum mod_hdcp_status read(struct mod_hdcp *hdcp, data_offset += cur_size; } }else { +int num_i2c_offsets =sizeof (hdcp_i2c_offsets) / +sizeof (hdcp_i2c_offsets[0 ]); +if (msg_id >= num_i2c_offsets) +return MOD_HDCP_STATUS_DDC_FAILURE ; + success = hdcp->config.ddc.funcs.read_i2c( hdcp->config.ddc.handle, HDCP_I2C_ADDR,
@@ -219,11 +229,16 @@ static enum mod_hdcp_status write(struct mod_hdcp *hdcp,uint32_t cur_size =0 ;uint32_t data_offset =0 ; -if (msg_id ==MOD_HDCP_MESSAGE_ID_INVALID ) { +if (msg_id ==MOD_HDCP_MESSAGE_ID_INVALID || + msg_id >=MOD_HDCP_MESSAGE_ID_MAX )return MOD_HDCP_STATUS_DDC_FAILURE ; - }if (is_dp_hdcp (hdcp)) { +int num_dpcd_addrs =sizeof (hdcp_dpcd_addrs) / +sizeof (hdcp_dpcd_addrs[0 ]); +if (msg_id >= num_dpcd_addrs) +return MOD_HDCP_STATUS_DDC_FAILURE ; +while (buf_len >0 ) { cur_size =MIN (buf_len,HDCP_MAX_AUX_TRANSACTION_SIZE ); success = hdcp->config.ddc.funcs.write_dpcd(
@@ -239,6 +254,11 @@ static enum mod_hdcp_status write(struct mod_hdcp *hdcp, data_offset += cur_size; } }else { +int num_i2c_offsets =sizeof (hdcp_i2c_offsets) / +sizeof (hdcp_i2c_offsets[0 ]); +if (msg_id >= num_i2c_offsets) +return MOD_HDCP_STATUS_DDC_FAILURE ; + hdcp->buf[0 ] = hdcp_i2c_offsets[msg_id];memmove (&hdcp->buf[1 ], buf, buf_len); success = hdcp->config.ddc.funcs.write_i2c(
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 10/47 drm/amd/display: Check num_valid_sets before accessing reader_wm_sets[]
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit b38a4815f79b87efb196cd5121579fc51e29a7fb ]
[WHY & HOW]num_valid_sets needs to be checked to avoid a negative index when accessing reader_wm_sets[num_valid_sets - 1].
This fixes an OVERRUN issue reported by Coverity.
--- drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c +2 -1
@@ -489,7 +489,8 @@ static void build_watermark_ranges(struct clk_bw_params *bw_params, struct pp_sm ranges->reader_wm_sets[num_valid_sets].max_fill_clk_mhz =PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX ;/* Modify previous watermark range to cover up to max */ - ranges->reader_wm_sets[num_valid_sets -1 ].max_fill_clk_mhz =PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX ; +if (num_valid_sets >0 ) + ranges->reader_wm_sets[num_valid_sets -1 ].max_fill_clk_mhz =PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX ; } num_valid_sets++; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 11/47 drm/amd/display: Check msg_id before processing transcation
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit fa71face755e27dc44bc296416ebdf2c67163316 ]
[WHY & HOW]HDCP_MESSAGE_ID_INVALID (-1) is not a valid msg_id nor is it a valid array index, and it needs checking before used.
This fixes 4 OVERRUN issues reported by Coverity.
--- drivers/gpu/drm/amd/display/dc/hdcp/hdcp_msg.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/hdcp/hdcp_msg.c +15 -2
@@ -131,13 +131,21 @@ static bool hdmi_14_process_transaction(const uint8_t hdcp_i2c_addr_link_primary =0x3a ;/* 0x74 >> 1*/ const uint8_t hdcp_i2c_addr_link_secondary =0x3b ;/* 0x76 >> 1*/ struct i2c_command i2c_command; -uint8_t offset = hdcp_i2c_offsets[message_info->msg_id]; +uint8_t offset;struct i2c_payload i2c_payloads[] = { - { true,0 ,1 , &offset }, + { true,0 ,1 ,0 },/* actual hdcp payload, will be filled later, zeroed for now*/ {0 } }; +if (message_info->msg_id ==HDCP_MESSAGE_ID_INVALID ) { +DC_LOG_ERROR ("%s: Invalid message_info msg_id - %d\n" , __func__, message_info->msg_id); +return false; + } + + offset = hdcp_i2c_offsets[message_info->msg_id]; + i2c_payloads[0 ].data = &offset; +switch (message_info->link) {case HDCP_LINK_SECONDARY : i2c_payloads[0 ].address = hdcp_i2c_addr_link_secondary;
@@ -311,6 +319,11 @@ static bool dp_11_process_transaction( struct dc_link *link, struct hdcp_protection_message *message_info) { +if (message_info->msg_id ==HDCP_MESSAGE_ID_INVALID ) { +DC_LOG_ERROR ("%s: Invalid message_info msg_id - %d\n" , __func__, message_info->msg_id); +return false; + } + return dpcd_access_helper( link, message_info->length,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 12/47 drm/amd/display: Fix Coverity INTEGER_OVERFLOW within dal_gpio_service_create
In reply to Sasha LevinFrom: Hersen Wu <[email protected]>
[ Upstream commit c6077aa66fa230d12f37fef01161ef080d13b726 ]
[Why]
For subtraction, coverity reports integer overflow warning message when variable type is uint32_t.
[How]
Change variable type to int32_t.
--- drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c +2 -2
@@ -58,7 +58,7 @@ struct gpio_service *dal_gpio_service_create( struct dc_context *ctx) {struct gpio_service *service; -uint32_t index_of_id; +int32_t index_of_id; service =kzalloc (sizeof (struct gpio_service ),GFP_KERNEL );
@@ -114,7 +114,7 @@ struct gpio_service *dal_gpio_service_create(return service; failure_2: -while (index_of_id) { +while (index_of_id >0 ) { --index_of_id;kfree (service->busyness[index_of_id]); }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 13/47 drm/amd/amdgpu: Check tbo resource pointer
In reply to Sasha LevinFrom: Asad Kamal <[email protected]>
[ Upstream commit 6cd2b872643bb29bba01a8ac739138db7bd79007 ]
Validate tbo resource pointer, skip if NULL
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -1
@@ -4406,7 +4406,8 @@ static int amdgpu_device_recover_vram(struct amdgpu_device *adev) shadow = vmbo->shadow;/* No need to recover an evicted BO */ -if (shadow->tbo.resource->mem_type !=TTM_PL_TT || +if (!shadow->tbo.resource || + shadow->tbo.resource->mem_type !=TTM_PL_TT || shadow->tbo.resource->start ==AMDGPU_BO_INVALID_OFFSET || shadow->parent->tbo.resource->mem_type !=TTM_PL_VRAM )continue ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 14/47 drm/amdgpu: Fix out-of-bounds write warning
In reply to Sasha LevinFrom: Ma Jun <[email protected]>
[ Upstream commit be1684930f5262a622d40ce7a6f1423530d87f89 ]
Check the ring type value to fix the out-of-bounds write warning
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1 -1
@@ -263,7 +263,7 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, ring->max_dw = max_dw; ring->hw_prio = hw_prio; -if (!ring->no_scheduler) { +if (!ring->no_scheduler && ring->funcs->type <AMDGPU_HW_IP_NUM ) { hw_ip = ring->funcs->type; num_sched = &adev->gpu_sched[hw_ip][hw_prio].num_scheds; adev->gpu_sched[hw_ip][hw_prio].sched[(*num_sched)++] =
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 15/47 drm/amdgpu: Fix out-of-bounds read of df_v1_7_channel_number
In reply to Sasha LevinFrom: Ma Jun <[email protected]>
[ Upstream commit d768394fa99467bcf2703bde74ddc96eeb0b71fa ]
Check the fb_channel_number range to avoid the array out-of-bounds read error
--- drivers/gpu/drm/amd/amdgpu/df_v1_7.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/df_v1_7.c +2 -0
@@ -70,6 +70,8 @@ static u32 df_v1_7_get_hbm_channel_number(struct amdgpu_device *adev)int fb_channel_number; fb_channel_number = adev->df.funcs->get_fb_channel_number (adev); +if (fb_channel_number >=ARRAY_SIZE (df_v1_7_channel_number)) + fb_channel_number =0 ;return df_v1_7_channel_number[fb_channel_number]; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 16/47 drm/amdgpu: fix ucode out-of-bounds read warning
In reply to Sasha LevinFrom: Tim Huang <[email protected]>
[ Upstream commit 8944acd0f9db33e17f387fdc75d33bb473d7936f ]
Clear warning that read ucode[] may out-of-bounds.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +3 -0
@@ -213,6 +213,9 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,struct amdgpu_firmware_info *ucode; id =fw_type_convert (cgs_device, type); +if (id >=AMDGPU_UCODE_ID_MAXIMUM ) +return -EINVAL ; + ucode = &adev->firmware.ucode[id];if (ucode->fw ==NULL )return -EINVAL ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 17/47 drm/amdgpu: fix mc_data out-of-bounds read warning
In reply to Sasha LevinFrom: Tim Huang <[email protected]>
[ Upstream commit 51dfc0a4d609fe700750a62f41447f01b8c9ea50 ]
Clear warning that read mc_data[i-1] may out-of-bounds.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c +2 -0
@@ -1475,6 +1475,8 @@ int amdgpu_atombios_init_mc_reg_table(struct amdgpu_device *adev, (u32 )le32_to_cpu (*((u32 *)reg_data + j)); j++; }else if ((reg_table->mc_reg_address[i].pre_reg_data &LOW_NIBBLE_MASK ) ==DATA_EQU_PREV ) { +if (i ==0 ) +continue ; reg_table->mc_reg_table_entry[num_ranges].mc_data[i] = reg_table->mc_reg_table_entry[num_ranges].mc_data[i -1 ]; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 18/47 drm/amdkfd: Reconcile the definition and use of oem_id in struct kfd_topology_device
In reply to Sasha LevinFrom: Michael Chen <[email protected]>
[ Upstream commit 10f624ef239bd136cdcc5bbc626157a57b938a31 ]
Currently oem_id is defined as uint8_t[6] and casted to uint64_t* in some use case. This would lead code scanner to complain about access beyond. Re-define it in union to enforce 8-byte size and alignment to avoid potential issue.
--- drivers/gpu/drm/amd/amdkfd/kfd_crat.h | 2 -- drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 3 +-- drivers/gpu/drm/amd/amdkfd/kfd_topology.h | 5 ++++- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_crat.h +0 -2
@@ -42,8 +42,6 @@#define CRAT_OEMTABLEID_LENGTH 8#define CRAT_RESERVED_LENGTH 6 -#define CRAT_OEMID_64BIT_MASK ((1ULL << (CRAT_OEMID_LENGTH * 8)) - 1) -/* Compute Unit flags */ #define COMPUTE_UNIT_CPU (1 << 0)/* Create Virtual CRAT for CPU */ #define COMPUTE_UNIT_GPU (1 << 1)/* Create Virtual CRAT for GPU */
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +1 -2
@@ -910,8 +910,7 @@ static void kfd_update_system_properties(void) dev =list_last_entry (&topology_device_list, struct kfd_topology_device, list);if (dev) { - sys_props.platform_id = - (*((uint64_t *)dev->oem_id)) &CRAT_OEMID_64BIT_MASK ; + sys_props.platform_id = dev->oem_id64; sys_props.platform_oem = *((uint64_t *)dev->oem_table_id); sys_props.platform_rev = dev->oem_revision; }
drivers/gpu/drm/amd/amdkfd/kfd_topology.h +4 -1
@@ -184,7 +184,10 @@ struct kfd_topology_device {struct attribute attr_gpuid;struct attribute attr_name;struct attribute attr_props; -uint8_t oem_id[CRAT_OEMID_LENGTH ]; +union { +uint8_t oem_id[CRAT_OEMID_LENGTH ]; +uint64_t oem_id64; + };uint8_t oem_table_id[CRAT_OEMTABLEID_LENGTH ];uint32_t oem_revision; };
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 19/47 drm/amdgpu/pm: Check input value for CUSTOM profile mode setting on legacy SOCs
In reply to Sasha LevinFrom: Ma Jun <[email protected]>
[ Upstream commit df0a9bd92fbbd3fcafcb2bce6463c9228a3e6868 ]
Check the input value for CUSTOM profile mode setting on legacy SOCs. Otherwise we may use uninitalized value of input[]
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c | 2 +- drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c +1 -1
@@ -5596,7 +5596,7 @@ static int smu7_set_power_profile_mode(struct pp_hwmgr *hwmgr, long *input, uint mode = input[size];switch (mode) {case PP_SMC_POWER_PROFILE_CUSTOM : -if (size <8 && size !=0 ) +if (size !=8 && size !=0 )return -EINVAL ;/* If only CUSTOM is passed in, use the saved values. Check * that we actually have a CUSTOM profile by ensuring that
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c +6 -2
@@ -4098,9 +4098,11 @@ static int vega20_set_power_profile_mode(struct pp_hwmgr *hwmgr, long *input, uiif (power_profile_mode ==PP_SMC_POWER_PROFILE_CUSTOM ) {struct vega20_hwmgr *data = (struct vega20_hwmgr *)(hwmgr->backend); -if (size ==0 && !data->is_custom_profile_set) + +if (size !=10 && size !=0 )return -EINVAL ; -if (size <10 && size !=0 ) + +if (size ==0 && !data->is_custom_profile_set)return -EINVAL ; result = vega20_get_activity_monitor_coeff(hwmgr,
@@ -4162,6 +4164,8 @@ static int vega20_set_power_profile_mode(struct pp_hwmgr *hwmgr, long *input, ui activity_monitor.Fclk_PD_Data_error_coeff = input[8 ]; activity_monitor.Fclk_PD_Data_error_rate_coeff = input[9 ];break ; +default : +return -EINVAL ; } result = vega20_set_activity_monitor_coeff(hwmgr,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 20/47 drm/amdgpu: fix the waring dereferencing hive
In reply to Sasha LevinFrom: Jesse Zhang <[email protected]>
[ Upstream commit 1940708ccf5aff76de4e0b399f99267c93a89193 ]
Check the amdgpu_hive_info *hive that maybe is NULL.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +3 -0
@@ -1178,6 +1178,9 @@ static void psp_xgmi_reflect_topology_info(struct psp_context *psp,uint8_t dst_num_links = node_info.num_links; hive =amdgpu_get_xgmi_hive (psp->adev); +if (WARN_ON (!hive)) +return ; +list_for_each_entry (mirror_adev, &hive->device_list, gmc.xgmi.head) {struct psp_xgmi_topology_info *mirror_top_info;int j;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 21/47 drm/amdgpu: the warning dereferencing obj for nbio_v7_4
In reply to Sasha LevinFrom: Jesse Zhang <[email protected]>
[ Upstream commit d190b459b2a4304307c3468ed97477b808381011 ]
if ras_manager obj null, don't print NBIO err data
--- drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c +1 -1
@@ -370,7 +370,7 @@ static void nbio_v7_4_handle_ras_controller_intr_no_bifring(struct amdgpu_deviceelse WREG32_SOC15 (NBIO ,0 , mmBIF_DOORBELL_INT_CNTL, bif_doorbell_intr_cntl); -if (!ras->disable_ras_err_cnt_harvest) { +if (ras && !ras->disable_ras_err_cnt_harvest && obj) {/* * clear error status after ras_controller_intr * according to hw team and count ue number
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 22/47 drm/amdgpu: update type of buf size to u32 for eeprom functions
In reply to Sasha LevinFrom: Tao Zhou <[email protected]>
[ Upstream commit 2aadb520bfacec12527effce3566f8df55e5d08e ]
Avoid overflow issue.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c +3 -3
@@ -177,7 +177,7 @@ static int __amdgpu_eeprom_xfer(struct i2c_adapter *i2c_adap, u32 eeprom_addr,* Returns the number of bytes read/written; -errno on error. */ static int amdgpu_eeprom_xfer (struct i2c_adapter *i2c_adap,u32 eeprom_addr, -u8 *eeprom_buf,u16 buf_size,bool read) +u8 *eeprom_buf,u32 buf_size,bool read) {const struct i2c_adapter_quirks *quirks = i2c_adap->quirks;u16 limit;
@@ -224,7 +224,7 @@ static int amdgpu_eeprom_xfer(struct i2c_adapter *i2c_adap, u32 eeprom_addr,int amdgpu_eeprom_read (struct i2c_adapter *i2c_adap,u32 eeprom_addr,u8 *eeprom_buf, -u16 bytes) +u32 bytes) {return amdgpu_eeprom_xfer (i2c_adap, eeprom_addr, eeprom_buf, bytes, true);
@@ -232,7 +232,7 @@ int amdgpu_eeprom_read(struct i2c_adapter *i2c_adap,int amdgpu_eeprom_write (struct i2c_adapter *i2c_adap,u32 eeprom_addr,u8 *eeprom_buf, -u16 bytes) +u32 bytes) {return amdgpu_eeprom_xfer (i2c_adap, eeprom_addr, eeprom_buf, bytes, false);
drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.h +2 -2
@@ -28,10 +28,10 @@int amdgpu_eeprom_read (struct i2c_adapter *i2c_adap,u32 eeprom_addr,u8 *eeprom_buf, -u16 bytes); +u32 bytes);int amdgpu_eeprom_write (struct i2c_adapter *i2c_adap,u32 eeprom_addr,u8 *eeprom_buf, -u16 bytes); +u32 bytes);#endif
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 23/47 cpufreq: scmi: Avoid overflow of target_freq in fast switch
In reply to Sasha LevinFrom: Jagadeesh Kona <[email protected]>
[ Upstream commit 074cffb5020ddcaa5fafcc55655e5da6ebe8c831 ]
Conversion of target_freq to HZ in scmi_cpufreq_fast_switch() can lead to overflow if the multiplied result is greater than UINT_MAX, since type of target_freq is unsigned int. Avoid this overflow by assigning target_freq to unsigned long variable for converting it to HZ.
--- drivers/cpufreq/scmi-cpufreq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/scmi-cpufreq.c +2 -2
@@ -61,9 +61,9 @@ static unsigned int scmi_cpufreq_fast_switch(struct cpufreq_policy *policy, unsigned int target_freq) {struct scmi_data *priv = policy->driver_data; +unsigned long freq = target_freq; -if (!perf_ops->freq_set (ph, priv->domain_id, - target_freq *1000 , true)) +if (!perf_ops->freq_set (ph, priv->domain_id, freq *1000 , true))return target_freq;return 0 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 24/47 bpf, net: Use DEV_STAT_INC()
In reply to Sasha LevinFrom: yunshui <[email protected]>
[ Upstream commit d9cbd8343b010016fcaabc361c37720dcafddcbe ]
syzbot/KCSAN reported that races happen when multiple CPUs updating dev->stats.tx_error concurrently. Adopt SMP safe DEV_STATS_INC() to update the dev->stats fields.
--- net/core/filter.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/core/filter.c +4 -4
@@ -2255,12 +2255,12 @@ static int __bpf_redirect_neigh_v6(struct sk_buff *skb, struct net_device *dev, err =bpf_out_neigh_v6 (net, skb, dev, nh);if (unlikely (net_xmit_eval (err))) - dev->stats.tx_errors++; +DEV_STATS_INC (dev, tx_errors);else ret =NET_XMIT_SUCCESS ; goto out_xmit; out_drop: - dev->stats.tx_errors++; +DEV_STATS_INC (dev, tx_errors);kfree_skb (skb); out_xmit:return ret;
@@ -2360,12 +2360,12 @@ static int __bpf_redirect_neigh_v4(struct sk_buff *skb, struct net_device *dev, err =bpf_out_neigh_v4 (net, skb, dev, nh);if (unlikely (net_xmit_eval (err))) - dev->stats.tx_errors++; +DEV_STATS_INC (dev, tx_errors);else ret =NET_XMIT_SUCCESS ; goto out_xmit; out_drop: - dev->stats.tx_errors++; +DEV_STATS_INC (dev, tx_errors);kfree_skb (skb); out_xmit:return ret;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 25/47 PCI: al: Check IORESOURCE_BUS existence during probe
In reply to Sasha LevinFrom: Aleksandr Mishin <[email protected]>
[ Upstream commit a9927c2cac6e9831361e43a14d91277818154e6a ]
If IORESOURCE_BUS is not provided in Device Tree it will be fabricated in of_pci_parse_bus_range(), so NULL pointer dereference should not happen here.
But that's hard to verify, so check for NULL anyway.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/pci/controller/dwc/pcie-al.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/pci/controller/dwc/pcie-al.c +13 -3
@@ -242,18 +242,24 @@ static struct pci_ops al_child_pci_ops = { .write = pci_generic_config_write, }; -static void al_pcie_config_prepare (struct al_pcie *pcie) +static int al_pcie_config_prepare (struct al_pcie *pcie) {struct al_pcie_target_bus_cfg *target_bus_cfg;struct pcie_port *pp = &pcie->pci->pp;unsigned int ecam_bus_mask; +struct resource_entry *ft;u32 cfg_control_offset; +struct resource *bus;u8 subordinate_bus;u8 secondary_bus;u32 cfg_control;u32 reg; -struct resource *bus =resource_list_first_type (&pp->bridge->windows,IORESOURCE_BUS )->res; + ft =resource_list_first_type (&pp->bridge->windows,IORESOURCE_BUS ); +if (!ft) +return -ENODEV ; + + bus = ft->res; target_bus_cfg = &pcie->target_bus_cfg; ecam_bus_mask = (pcie->ecam_size >>PCIE_ECAM_BUS_SHIFT ) -1 ;
@@ -287,6 +293,8 @@ static void al_pcie_config_prepare(struct al_pcie *pcie)FIELD_PREP (CFG_CONTROL_SEC_BUS_MASK , secondary_bus);al_pcie_controller_writel (pcie, cfg_control_offset, reg); + +return 0 ; }static int al_pcie_host_init (struct pcie_port *pp)
@@ -305,7 +313,9 @@ static int al_pcie_host_init(struct pcie_port *pp)if (rc)return rc; -al_pcie_config_prepare (pcie); + rc =al_pcie_config_prepare (pcie); +if (rc) +return rc;return 0 ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 26/47 hwspinlock: Introduce hwspin_lock_bust()
In reply to Sasha LevinFrom: Richard Maina <[email protected]>
[ Upstream commit 7c327d56597d8de1680cf24e956b704270d3d84a ]
When a remoteproc crashes or goes down unexpectedly this can result in a state where locks held by the remoteproc will remain locked possibly resulting in deadlock. This new API hwspin_lock_bust() allows hwspinlock implementers to define a bust operation for freeing previously acquired hwspinlocks after verifying ownership of the acquired lock.
--- Documentation/locking/hwspinlock.rst | 11 ++++++++++ drivers/hwspinlock/hwspinlock_core.c | 28 ++++++++++++++++++++++++ drivers/hwspinlock/hwspinlock_internal.h | 3 +++ include/linux/hwspinlock.h | 6 +++++ 4 files changed, 48 insertions(+)
Documentation/locking/hwspinlock.rst +11 -0
@@ -85,6 +85,17 @@ is already free). Should be called from a process context (might sleep). +:: + + int hwspin_lock_bust(struct hwspinlock *hwlock, unsigned int id); + +After verifying the owner of the hwspinlock, release a previously acquired +hwspinlock; returns 0 on success, or an appropriate error code on failure +(e.g. -EOPNOTSUPP if the bust operation is not defined for the specific +hwspinlock). + +Should be called from a process context (might sleep). + :: int hwspin_lock_timeout(struct hwspinlock *hwlock, unsigned int timeout);
drivers/hwspinlock/hwspinlock_core.c +28 -0
@@ -302,6 +302,34 @@ void __hwspin_unlock(struct hwspinlock *hwlock, int mode, unsigned long *flags) }EXPORT_SYMBOL_GPL (__hwspin_unlock); +/** +* hwspin_lock_bust() - bust a specific hwspinlock +* @hwlock: a previously-acquired hwspinlock which we want to bust +* @id: identifier of the remote lock holder, if applicable +* +* This function will bust a hwspinlock that was previously acquired as +* long as the current owner of the lock matches the id given by the caller. +* +* Context: Process context. +* +* Returns: 0 on success, or -EINVAL if the hwspinlock does not exist, or +* the bust operation fails, and -EOPNOTSUPP if the bust operation is not +* defined for the hwspinlock. +*/ +int hwspin_lock_bust (struct hwspinlock *hwlock,unsigned int id) +{ +if (WARN_ON (!hwlock)) +return -EINVAL ; + +if (!hwlock->bank->ops->bust) { +pr_err ("bust operation not defined\n" ); +return -EOPNOTSUPP ; + } + +return hwlock->bank->ops->bust (hwlock, id); +} +EXPORT_SYMBOL_GPL (hwspin_lock_bust); +/** * of_hwspin_lock_simple_xlate - translate hwlock_spec to return a lock id * @bank: the hwspinlock device bank
drivers/hwspinlock/hwspinlock_internal.h +3 -0
@@ -21,6 +21,8 @@ struct hwspinlock_device;* @trylock: make a single attempt to take the lock. returns 0 on * failure and true on success. may _not_ sleep. * @unlock: release the lock. always succeed. may _not_ sleep. +* @bust: optional, platform-specific bust handler, called by hwspinlock +* core to bust a specific lock. * @relax: optional, platform-specific relax handler, called by hwspinlock * core while spinning on a lock, between two successive * invocations of @trylock. may _not_ sleep.
@@ -28,6 +30,7 @@ struct hwspinlock_device;struct hwspinlock_ops {int (*trylock)(struct hwspinlock *lock);void (*unlock)(struct hwspinlock *lock); +int (*bust)(struct hwspinlock *lock,unsigned int id);void (*relax)(struct hwspinlock *lock); };
include/linux/hwspinlock.h +6 -0
@@ -68,6 +68,7 @@ int __hwspin_lock_timeout(struct hwspinlock *, unsigned int, int,int __hwspin_trylock (struct hwspinlock *,int ,unsigned long *);void __hwspin_unlock (struct hwspinlock *,int ,unsigned long *);int of_hwspin_lock_get_id_byname (struct device_node *np,const char *name); +int hwspin_lock_bust (struct hwspinlock *hwlock,unsigned int id);int devm_hwspin_lock_free (struct device *dev,struct hwspinlock *hwlock);struct hwspinlock *devm_hwspin_lock_request (struct device *dev); struct hwspinlock *devm_hwspin_lock_request_specific(struct device *dev,
@@ -127,6 +128,11 @@ void __hwspin_unlock(struct hwspinlock *hwlock, int mode, unsigned long *flags) { } +static inline int hwspin_lock_bust (struct hwspinlock *hwlock,unsigned int id) +{ +return 0 ; +} +static inline int of_hwspin_lock_get_id (struct device_node *np,int index) {return 0 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 27/47 gpiolib: cdev: Add INIT_KFIFO() for linereq events
In reply to Sasha LevinFrom: Kent Gibson <[email protected]>
[ Upstream commit 35d848e7a1cbba2649ed98cf58e0cdc7ee560c7a ]
The initialisation of the linereq events kfifo relies on the struct being zeroed and a subsequent call to kfifo_alloc(). The call to kfifo_alloc() is deferred until edge detection is first enabled for the linereq. If the kfifo is inadvertently accessed before the call to kfifo_alloc(), as was the case in a recently discovered bug, it behaves as a FIFO of size 1 with an element size of 0, so writes and reads to the kfifo appear successful but copy no actual data.
As a defensive measure, initialise the kfifo with INIT_KFIFO() when the events kfifo is constructed. This initialises the kfifo element size and zeroes its data pointer, so any inadvertant access prior to the kfifo_alloc() call will trigger an oops.
--- drivers/gpio/gpiolib-cdev.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpio/gpiolib-cdev.c +1 -0
@@ -1454,6 +1454,7 @@ static int linereq_create(struct gpio_device *gdev, void __user *ip)mutex_init (&lr->config_mutex);init_waitqueue_head (&lr->wait); +INIT_KFIFO (lr->events); lr->event_buffer_size = ulr.event_buffer_size;if (lr->event_buffer_size ==0 ) lr->event_buffer_size = ulr.num_lines *16 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 28/47 smack: tcp: ipv4, fix incorrect labeling
In reply to Sasha LevinFrom: Casey Schaufler <[email protected]>
[ Upstream commit 2fe209d0ad2e2729f7e22b9b31a86cc3ff0db550 ]
Currently, Smack mirrors the label of incoming tcp/ipv4 connections:
when a label 'foo' connects to a label 'bar' with tcp/ipv4, 'foo' always gets 'foo' in returned ipv4 packets. So,
1) returned packets are incorrectly labeled ('foo' instead of 'bar')
2) 'bar' can write to 'foo' without being authorized to write.
Here is a scenario how to see this:
* Take two machines, let's call them C and S,
with active Smack in the default state
(no settings, no rules, no labeled hosts, only builtin labels)
* At S, add Smack rule 'foo bar w'
(labels 'foo' and 'bar' are instantiated at S at this moment)
* At S, at label 'bar', launch a program
that listens for incoming tcp/ipv4 connections
* From C, at label 'foo', connect to the listener at S. (label 'foo' is instantiated at C at this moment) Connection succeedes and works.
* Send some data in both directions.
* Collect network traffic of this connection.
All packets in both directions are labeled with the CIPSO of the label 'foo'. Hence, label 'bar' writes to 'foo' without being authorized, and even without ever being known at C.
If anybody cares: exactly the same happens with DCCP.
This behavior 1st manifested in release 2.6.29.4 (see Fixes below) and it looks unintentional. At least, no explanation was provided.
I changed returned packes label into the 'bar', to bring it into line with the Smack documentation claims.
--- security/smack/smack_lsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/smack/smack_lsm.c +1 -1
@@ -4225,7 +4225,7 @@ static int smack_inet_conn_request(const struct sock *sk, struct sk_buff *skb,rcu_read_unlock ();if (hskp ==NULL ) - rc =netlbl_req_setattr (req, &skp->smk_netlabel); + rc =netlbl_req_setattr (req, &ssp->smk_out->smk_netlabel);else netlbl_req_delattr (req);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 29/47 drm/bridge: tc358767: Check if fully initialized before signalling HPD event via IRQ
In reply to Sasha LevinFrom: Marek Vasut <[email protected]>
[ Upstream commit 162e48cb1d84c2c966b649b8ac5c9d4f75f6d44f ]
Make sure the connector is fully initialized before signalling any HPD events via drm_kms_helper_hotplug_event(), otherwise this may lead to NULL pointer dereference.
--- drivers/gpu/drm/bridge/tc358767.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/tc358767.c +1 -1
@@ -1527,7 +1527,7 @@ static irqreturn_t tc_irq_handler(int irq, void *arg)dev_err (tc->dev,"syserr %x\n" , stat); } -if (tc->hpd_pin >=0 && tc->bridge.dev) { +if (tc->hpd_pin >=0 && tc->bridge.dev && tc->aux.drm_dev) {/* * H is triggered when the GPIO goes high. *
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 30/47 wifi: cfg80211: make hash table duplicates more survivable
In reply to Sasha LevinFrom: Johannes Berg <[email protected]>
[ Upstream commit 7f12e26a194d0043441f870708093d9c2c3bad7d ]
Jiazi Li reported that they occasionally see hash table duplicates as evidenced by the WARN_ON() in rb_insert_bss() in this code. It isn't clear how that happens, nor have I been able to reproduce it, but if it does happen, the kernel crashes later, when it tries to unhash the entry that's now not hashed.
Try to make this situation more survivable by removing the BSS from the list(s) as well, that way it's fully leaked here (as had been the intent in the hash insert error path), and no longer reachable through the list(s) so it shouldn't be unhashed again later.
--- net/wireless/scan.c | 46 +++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-)
net/wireless/scan.c +34 -12
@@ -1517,7 +1517,7 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy, }EXPORT_SYMBOL (cfg80211_get_bss); -static void rb_insert_bss (struct cfg80211_registered_device *rdev, +static bool rb_insert_bss (struct cfg80211_registered_device *rdev,struct cfg80211_internal_bss *bss) {struct rb_node **p = &rdev->bss_tree.rb_node;
@@ -1533,7 +1533,7 @@ static void rb_insert_bss(struct cfg80211_registered_device *rdev,if (WARN_ON (!cmp)) {/* will sort of leak this BSS */ -return ; +return false; }if (cmp <0 )
@@ -1544,6 +1544,7 @@ static void rb_insert_bss(struct cfg80211_registered_device *rdev,rb_link_node (&bss->rbn, parent, p);rb_insert_color (&bss->rbn, &rdev->bss_tree); +return true; } static struct cfg80211_internal_bss *
@@ -1570,6 +1571,34 @@ rb_find_bss(struct cfg80211_registered_device *rdev,return NULL ; } +static void cfg80211_insert_bss (struct cfg80211_registered_device *rdev, +struct cfg80211_internal_bss *bss) +{ +lockdep_assert_held (&rdev->bss_lock); + +if (!rb_insert_bss (rdev, bss)) +return ; +list_add_tail (&bss->list, &rdev->bss_list); + rdev->bss_entries++; +} + +static void cfg80211_rehash_bss (struct cfg80211_registered_device *rdev, +struct cfg80211_internal_bss *bss) +{ +lockdep_assert_held (&rdev->bss_lock); + +rb_erase (&bss->rbn, &rdev->bss_tree); +if (!rb_insert_bss (rdev, bss)) { +list_del (&bss->list); +if (!list_empty (&bss->hidden_list)) +list_del_init (&bss->hidden_list); +if (!list_empty (&bss->pub.nontrans_list)) +list_del_init (&bss->pub.nontrans_list); + rdev->bss_entries--; + } + rdev->bss_generation++; +} +static bool cfg80211_combine_bsses (struct cfg80211_registered_device *rdev,struct cfg80211_internal_bss *new) {
@@ -1845,9 +1874,7 @@ cfg80211_bss_update(struct cfg80211_registered_device *rdev,bss_ref_get (rdev, pbss); } -list_add_tail (&new->list, &rdev->bss_list); - rdev->bss_entries++; -rb_insert_bss (rdev, new); +cfg80211_insert_bss (rdev, new); found = new; }
@@ -2712,10 +2739,7 @@ void cfg80211_update_assoc_bss_entry(struct wireless_dev *wdev,if (!WARN_ON (!__cfg80211_unlink_bss (rdev, new))) rdev->bss_generation++; } - -rb_erase (&cbss->rbn, &rdev->bss_tree); -rb_insert_bss (rdev, cbss); - rdev->bss_generation++; +cfg80211_rehash_bss (rdev, cbss);list_for_each_entry_safe (nontrans_bss, tmp, &cbss->pub.nontrans_list,
@@ -2723,9 +2747,7 @@ void cfg80211_update_assoc_bss_entry(struct wireless_dev *wdev, bss =container_of (nontrans_bss, struct cfg80211_internal_bss, pub); bss->pub.channel = chan; -rb_erase (&bss->rbn, &rdev->bss_tree); -rb_insert_bss (rdev, bss); - rdev->bss_generation++; +cfg80211_rehash_bss (rdev, bss); } done:
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 31/47 drm/amd/display: added NULL check at start of dc_validate_stream
In reply to Sasha LevinFrom: winstang <[email protected]>
[ Upstream commit 26c56049cc4f1705b498df013949427692a4b0d5 ]
[Why]
prevent invalid memory access
[How]
check if dc and stream are NULL
--- drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/display/dc/core/dc_resource.c +3 -0
@@ -2872,6 +2872,9 @@ void resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,enum dc_status dc_validate_stream (struct dc *dc,struct dc_stream_state *stream) { +if (dc ==NULL || stream ==NULL ) +return DC_ERROR_UNEXPECTED ; +struct dc_link *link = stream->link;struct timing_generator *tg = dc->res_pool->timing_generators[0 ];enum dc_status res =DC_OK ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 32/47 drm/amd/display: Skip wbscl_set_scaler_filter if filter is null
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit c4d31653c03b90e51515b1380115d1aedad925dd ]
Callers can pass null in filter (i.e. from returned from the function wbscl_get_filter_coeffs_16p) and a null check is added to ensure that is not the case.
This fixes 4 NULL_RETURNS issues reported by Coverity.
--- drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dwb_scl.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dwb_scl.c +3 -0
@@ -690,6 +690,9 @@ static void wbscl_set_scaler_filter(int pair;uint16_t odd_coef, even_coef; +if (!filter) +return ; +for (phase =0 ; phase < (NUM_PHASES /2 +1 ); phase++) {for (pair =0 ; pair < tap_pairs; pair++) { even_coef = filter[phase * taps +2 * pair];
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 33/47 ALSA: vmaster: Return error for invalid input values
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit 10457f5042b4890a667e2f15a2e783490dda44d2 ]
So far the vmaster code has been tolerant about the input values and accepts any values by correcting internally. But now our own selftest starts complaining about this behavior, so let's be picky and change the behavior to return -EINVAL for invalid input values instead.
--- sound/core/vmaster.c | 8 ++++++++ 1 file changed, 8 insertions(+)
sound/core/vmaster.c +8 -0
@@ -204,6 +204,12 @@ static int follower_put(struct snd_kcontrol *kcontrol, err =follower_init (follower);if (err <0 )return err; +for (ch =0 ; ch < follower->info.count; ch++) { +if (ucontrol->value.integer.value[ch] < follower->info.min_val || + ucontrol->value.integer.value[ch] > follower->info.max_val) +return -EINVAL ; + } +for (ch =0 ; ch < follower->info.count; ch++) {if (follower->vals[ch] != ucontrol->value.integer.value[ch]) { changed =1 ;
@@ -344,6 +350,8 @@ static int master_put(struct snd_kcontrol *kcontrol, new_val = ucontrol->value.integer.value[0 ];if (new_val == old_val)return 0 ; +if (new_val < master->info.min_val || new_val > master->info.max_val) +return -EINVAL ; err =sync_followers (master, old_val, new_val);if (err <0 )
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 34/47 ELF: fix kernel.randomize_va_space double read
In reply to Sasha LevinFrom: Alexey Dobriyan <[email protected]>
[ Upstream commit 2a97388a807b6ab5538aa8f8537b2463c6988bd2 ]
ELF loader uses "randomize_va_space" twice. It is sysctl and can change at any moment, so 2 loads could see 2 different values in theory with unpredictable consequences.
Issue exactly one load for consistent value across one exec.
--- fs/binfmt_elf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/binfmt_elf.c +3 -2
@@ -1008,7 +1008,8 @@ static int load_elf_binary(struct linux_binprm *bprm)if (elf_read_implies_exec (*elf_ex, executable_stack)) current->personality |=READ_IMPLIES_EXEC ; -if (!(current->personality &ADDR_NO_RANDOMIZE ) && randomize_va_space) +const int snapshot_randomize_va_space =READ_ONCE (randomize_va_space); +if (!(current->personality &ADDR_NO_RANDOMIZE ) && snapshot_randomize_va_space) current->flags |=PF_RANDOMIZE ;setup_new_exec (bprm);
@@ -1278,7 +1279,7 @@ static int load_elf_binary(struct linux_binprm *bprm) mm->end_data = end_data; mm->start_stack = bprm->p; -if ((current->flags &PF_RANDOMIZE ) && (randomize_va_space >1 )) { +if ((current->flags &PF_RANDOMIZE ) && (snapshot_randomize_va_space >1 )) {/* * For architectures with ELF randomization, when executing * a loader directly (i.e. no interpreter listed in ELF
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 35/47 udf: Avoid excessive partition lengths
In reply to Sasha LevinFrom: Jan Kara <[email protected]>
[ Upstream commit ebbe26fd54a9621994bc16b14f2ba8f84c089693 ]
Avoid mounting filesystems where the partition would overflow the 32-bits used for block number. Also refuse to mount filesystems where the partition length is so large we cannot safely index bits in a block bitmap.
--- fs/udf/super.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
fs/udf/super.c +15 -0
@@ -1076,12 +1076,19 @@ static int udf_fill_partdesc_info(struct super_block *sb,struct udf_part_map *map;struct udf_sb_info *sbi =UDF_SB (sb);struct partitionHeaderDesc *phd; +u32 sum;int err; map = &sbi->s_partmaps[p_index]; map->s_partition_len =le32_to_cpu (p->partitionLength);/* blocks */ map->s_partition_root =le32_to_cpu (p->partitionStartingLocation); +if (check_add_overflow (map->s_partition_root, map->s_partition_len, + &sum)) { +udf_err (sb,"Partition %d has invalid location %u + %u\n" , + p_index, map->s_partition_root, map->s_partition_len); +return -EFSCORRUPTED ; + }if (p->accessType ==cpu_to_le32 (PD_ACCESS_TYPE_READ_ONLY )) map->s_partition_flags |=UDF_PART_FLAG_READ_ONLY ;
@@ -1137,6 +1144,14 @@ static int udf_fill_partdesc_info(struct super_block *sb, bitmap->s_extPosition =le32_to_cpu ( phd->unallocSpaceBitmap.extPosition); map->s_partition_flags |=UDF_PART_FLAG_UNALLOC_BITMAP ; +/* Check whether math over bitmap won't overflow. */ +if (check_add_overflow (map->s_partition_len, +sizeof (struct spaceBitmapDesc ) <<3 , + &sum)) { +udf_err (sb,"Partition %d is too long (%u)\n" , p_index, + map->s_partition_len); +return -EFSCORRUPTED ; + }udf_debug ("unallocSpaceBitmap (part %d) @ %u\n" , p_index, bitmap->s_extPosition); }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 36/47 riscv: mm: Take memory hotplug read-lock during kernel page table dump
In reply to Sasha LevinFrom: Björn Töpel <[email protected]>
[ Upstream commit 37992b7f1097ba79ca75ba5a26ddcf0f54f91a08 ]
During memory hot remove, the ptdump functionality can end up touching stale data. Avoid any potential crashes (or worse), by holding the memory hotplug read-lock while traversing the page table.
This change is analogous to arm64's commit bf2b59f60ee1 ("arm64/mm:
Hold memory hotplug lock while walking for kernel page table dump").
--- arch/riscv/mm/ptdump.c | 3 +++ 1 file changed, 3 insertions(+)
arch/riscv/mm/ptdump.c +3 -0
@@ -6,6 +6,7 @@#include <linux/efi.h> #include <linux/init.h> #include <linux/debugfs.h> +#include <linux/memory_hotplug.h> #include <linux/seq_file.h> #include <linux/ptdump.h>
@@ -351,7 +352,9 @@ void ptdump_check_wx(void)static int ptdump_show (struct seq_file *m,void *v) { +get_online_mems ();ptdump_walk (m, m->private); +put_online_mems ();return 0 ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 37/47 usb: uas: set host status byte on data completion error
In reply to Sasha LevinFrom: Shantanu Goel <[email protected]>
[ Upstream commit 9d32685a251a754f1823d287df233716aa23bcb9 ]
Set the host status byte when a data completion error is encountered otherwise the upper layer may end up using the invalid zero'ed data. The following output was observed from scsi/sd.c prior to this fix.
[ 11.872824] sd 0:0:0:1: [sdf] tag#9 data cmplt err -75 uas-tag 1 inflight: [ 11.872826] sd 0:0:0:1: [sdf] tag#9 CDB: Read capacity(16) 9e 10 00 00 00 00 00 00 00 00 00 00 00 20 00 00 [ 11.872830] sd 0:0:0:1: [sdf] Sector size 0 reported, assuming 512.
--- drivers/usb/storage/uas.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/storage/uas.c +1 -0
@@ -422,6 +422,7 @@ static void uas_data_cmplt(struct urb *urb)uas_log_cmd_state (cmnd,"data cmplt err" , status);/* error: no data transfered */ scsi_set_resid (cmnd, sdb->length); +set_host_byte (cmnd,DID_ERROR ); }else {scsi_set_resid (cmnd, sdb->length - urb->actual_length); }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 38/47 drm/amd/display: Check HDCP returned status
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit 5d93060d430b359e16e7c555c8f151ead1ac614b ]
[WHAT & HOW]
Check mod_hdcp_execute_and_set() return values in authenticated_dp.
This fixes 3 CHECKED_RETURN issues reported by Coverity.
--- .../amd/display/modules/hdcp/hdcp1_execution.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_execution.c +9 -6
@@ -433,17 +433,20 @@ static enum mod_hdcp_status authenticated_dp(struct mod_hdcp *hdcp, }if (status ==MOD_HDCP_STATUS_SUCCESS ) -mod_hdcp_execute_and_set (mod_hdcp_read_bstatus, +if (!mod_hdcp_execute_and_set (mod_hdcp_read_bstatus, &input->bstatus_read, &status, - hdcp,"bstatus_read" ); + hdcp,"bstatus_read" )) + goto out;if (status ==MOD_HDCP_STATUS_SUCCESS ) -mod_hdcp_execute_and_set (check_link_integrity_dp, +if (!mod_hdcp_execute_and_set (check_link_integrity_dp, &input->link_integrity_check, &status, - hdcp,"link_integrity_check" ); + hdcp,"link_integrity_check" )) + goto out;if (status ==MOD_HDCP_STATUS_SUCCESS ) -mod_hdcp_execute_and_set (check_no_reauthentication_request_dp, +if (!mod_hdcp_execute_and_set (check_no_reauthentication_request_dp, &input->reauth_request_check, &status, - hdcp,"reauth_request_check" ); + hdcp,"reauth_request_check" )) + goto out; out:return status; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 39/47 cgroup: Protect css->cgroup write under css_set_lock
In reply to Sasha LevinFrom: Waiman Long <[email protected]>
[ Upstream commit 57b56d16800e8961278ecff0dc755d46c4575092 ]
The writing of css->cgroup associated with the cgroup root in rebind_subsystems() is currently protected only by cgroup_mutex. However, the reading of css->cgroup in both proc_cpuset_show() and proc_cgroup_show() is protected just by css_set_lock. That makes the readers susceptible to racing problems like data tearing or caching. It is also a problem that can be reported by KCSAN.
This can be fixed by using READ_ONCE() and WRITE_ONCE() to access css->cgroup. Alternatively, the writing of css->cgroup can be moved under css_set_lock as well which is done by this patch.
--- kernel/cgroup/cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/cgroup/cgroup.c +1 -1
@@ -1802,9 +1802,9 @@ int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask)RCU_INIT_POINTER (scgrp->subsys[ssid],NULL );rcu_assign_pointer (dcgrp->subsys[ssid], css); ss->root = dst_root; - css->cgroup = dcgrp;spin_lock_irq (&css_set_lock); + css->cgroup = dcgrp;WARN_ON (!list_empty (&dcgrp->e_csets[ss->id]));list_for_each_entry_safe (cset, cset_pos, &scgrp->e_csets[ss->id], e_cset_node[ss->id]) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 40/47 um: line: always fill *error_out in setup_one_line()
In reply to Sasha LevinFrom: Johannes Berg <[email protected]>
[ Upstream commit 824ac4a5edd3f7494ab1996826c4f47f8ef0f63d ]
The pointer isn't initialized by callers, but I have encountered cases where it's still printed; initialize it in all possible cases in setup_one_line().
--- arch/um/drivers/line.c | 2 ++ 1 file changed, 2 insertions(+)
arch/um/drivers/line.c +2 -0
@@ -383,6 +383,7 @@ int setup_one_line(struct line *lines, int n, char *init,parse_chan_pair (NULL , line, n, opts, error_out); err =0 ; } + *error_out ="configured as 'none'" ; }else {char *new =kstrdup (init,GFP_KERNEL );if (!new) {
@@ -406,6 +407,7 @@ int setup_one_line(struct line *lines, int n, char *init, } }if (err) { + *error_out ="failed to parse channel pair" ; line->init_str =NULL ; line->valid =0 ;kfree (new);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 41/47 devres: Initialize an uninitialized struct member
In reply to Sasha LevinFrom: Zijun Hu <[email protected]>
[ Upstream commit 56a20ad349b5c51909cf8810f7c79b288864ad33 ]
Initialize an uninitialized struct member for driver API devres_open_group().
--- drivers/base/devres.c | 1 + 1 file changed, 1 insertion(+)
drivers/base/devres.c +1 -0
@@ -562,6 +562,7 @@ void * devres_open_group(struct device *dev, void *id, gfp_t gfp) grp->id = grp;if (id) grp->id = id; + grp->color =0 ;spin_lock_irqsave (&dev->devres_lock, flags);add_dr (dev, &grp->node[0 ]);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 42/47 pci/hotplug/pnv_php: Fix hotplug driver crash on Powernv
In reply to Sasha LevinFrom: Krishna Kumar <[email protected]>
[ Upstream commit 335e35b748527f0c06ded9eebb65387f60647fda ]
The hotplug driver for powerpc (pci/hotplug/pnv_php.c) causes a kernel crash when we try to hot-unplug/disable the PCIe switch/bridge from the PHB.
The crash occurs because although the MSI data structure has been released during disable/hot-unplug path and it has been assigned with NULL, still during unregistration the code was again trying to explicitly disable the MSI which causes the NULL pointer dereference and kernel crash.
The patch fixes the check during unregistration path to prevent invoking pci_disable_msi/msix() since its data structure is already freed.
--- drivers/pci/hotplug/pnv_php.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/pci/hotplug/pnv_php.c +1 -2
@@ -38,7 +38,6 @@ static void pnv_php_disable_irq(struct pnv_php_slot *php_slot, bool disable_device) {struct pci_dev *pdev = php_slot->pdev; -int irq = php_slot->irq;u16 ctrl;if (php_slot->irq >0 ) {
@@ -57,7 +56,7 @@ static void pnv_php_disable_irq(struct pnv_php_slot *php_slot, php_slot->wq =NULL ; } -if (disable_device || irq >0 ) { +if (disable_device) {if (pdev->msix_enabled)pci_disable_msix (pdev);else if (pdev->msi_enabled)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 43/47 hwmon: (lm95234) Fix underflows seen when writing limit attributes
In reply to Sasha LevinFrom: Guenter Roeck <[email protected]>
[ Upstream commit af64e3e1537896337405f880c1e9ac1f8c0c6198 ]
DIV_ROUND_CLOSEST() after kstrtol() results in an underflow if a large negative number such as -9223372036854775808 is provided by the user. Fix it by reordering clamp_val() and DIV_ROUND_CLOSEST() operations.
--- drivers/hwmon/lm95234.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/hwmon/lm95234.c +5 -4
@@ -301,7 +301,8 @@ static ssize_t tcrit2_store(struct device *dev, struct device_attribute *attr,if (ret <0 )return ret; - val =clamp_val (DIV_ROUND_CLOSEST (val,1000 ),0 , index ?255 :127 ); + val =DIV_ROUND_CLOSEST (clamp_val (val,0 , (index ?255 :127 ) *1000 ), +1000 );mutex_lock (&data->update_lock); data->tcrit2[index] = val;
@@ -350,7 +351,7 @@ static ssize_t tcrit1_store(struct device *dev, struct device_attribute *attr,if (ret <0 )return ret; - val =clamp_val (DIV_ROUND_CLOSEST (val,1000 ),0 ,255 ); + val =DIV_ROUND_CLOSEST (clamp_val (val,0 ,255000 ),1000 );mutex_lock (&data->update_lock); data->tcrit1[index] = val;
@@ -391,7 +392,7 @@ static ssize_t tcrit1_hyst_store(struct device *dev,if (ret <0 )return ret; - val =DIV_ROUND_CLOSEST (val,1000 ); + val =DIV_ROUND_CLOSEST (clamp_val (val,-255000 ,255000 ),1000 ); val =clamp_val ((int )data->tcrit1[index] - val,0 ,31 );mutex_lock (&data->update_lock);
@@ -431,7 +432,7 @@ static ssize_t offset_store(struct device *dev, struct device_attribute *attr,return ret;/* Accuracy is 1/2 degrees C */ - val =clamp_val (DIV_ROUND_CLOSEST (val,500 ),-128 ,127 ); + val =DIV_ROUND_CLOSEST (clamp_val (val,-64000 ,63500 ),500 );mutex_lock (&data->update_lock); data->toffset[index] = val;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 44/47 hwmon: (w83627ehf) Fix underflows seen when writing limit attributes
In reply to Sasha LevinFrom: Guenter Roeck <[email protected]>
[ Upstream commit 5c1de37969b7bc0abcb20b86e91e70caebbd4f89 ]
DIV_ROUND_CLOSEST() after kstrtol() results in an underflow if a large negative number such as -9223372036854775808 is provided by the user. Fix it by reordering clamp_val() and DIV_ROUND_CLOSEST() operations.
--- drivers/hwmon/w83627ehf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hwmon/w83627ehf.c +2 -2
@@ -895,7 +895,7 @@ store_target_temp(struct device *dev, struct device_attribute *attr,if (err <0 )return err; - val =clamp_val (DIV_ROUND_CLOSEST (val,1000 ),0 ,127 ); + val =DIV_ROUND_CLOSEST (clamp_val (val,0 ,127000 ),1000 );mutex_lock (&data->update_lock); data->target_temp[nr] = val;
@@ -920,7 +920,7 @@ store_tolerance(struct device *dev, struct device_attribute *attr,return err;/* Limit the temp to 0C - 15C */ - val =clamp_val (DIV_ROUND_CLOSEST (val,1000 ),0 ,15 ); + val =DIV_ROUND_CLOSEST (clamp_val (val,0 ,15000 ),1000 );mutex_lock (&data->update_lock); reg =w83627ehf_read_value (data,W83627EHF_REG_TOLERANCE [nr]);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 45/47 libbpf: Add NULL checks to bpf_object__{prev_map,next_map}
In reply to Sasha LevinFrom: Andreas Ziegler <[email protected]>
[ Upstream commit cedc12c5b57f7efa6dbebfb2b140e8675f5a2616 ]
In the current state, an erroneous call to bpf_object__find_map_by_name(NULL, ...) leads to a segmentation fault through the following call chain:
bpf_object__find_map_by_name(obj = NULL, ...)
-> bpf_object__for_each_map(pos, obj = NULL)
-> bpf_object__next_map((obj = NULL), NULL)
-> return (obj = NULL)->maps
While calling bpf_object__find_map_by_name with obj = NULL is obviously incorrect, this should not lead to a segmentation fault but rather be handled gracefully.
As __bpf_map__iter already handles this situation correctly, we can delegate the check for the regular case there and only add a check in case the prev or next parameter is NULL.
--- tools/lib/bpf/libbpf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/lib/bpf/libbpf.c +2 -2
@@ -8729,7 +8729,7 @@ __bpf_map__iter(const struct bpf_map *m, const struct bpf_object *obj, int i)struct bpf_map *bpf_map__next (const struct bpf_map *prev,const struct bpf_object *obj) { -if (prev ==NULL ) +if (prev ==NULL && obj !=NULL )return obj->maps;return __bpf_map__iter (prev, obj,1 );
@@ -8738,7 +8738,7 @@ bpf_map__next(const struct bpf_map *prev, const struct bpf_object *obj)struct bpf_map *bpf_map__prev (const struct bpf_map *next,const struct bpf_object *obj) { -if (next ==NULL ) { +if (next ==NULL && obj !=NULL ) {if (!obj->nr_maps)return NULL ;return obj->maps + obj->nr_maps -1 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 46/47 wifi: mwifiex: Do not return unused priv in mwifiex_get_priv_by_id()
In reply to Sasha LevinFrom: Sascha Hauer <[email protected]>
[ Upstream commit c145eea2f75ff7949392aebecf7ef0a81c1f6c14 ]
mwifiex_get_priv_by_id() returns the priv pointer corresponding to the bss_num and bss_type, but without checking if the priv is actually currently in use.
Unused priv pointers do not have a wiphy attached to them which can lead to NULL pointer dereferences further down the callstack. Fix this by returning only used priv pointers which have priv->bss_mode set to something else than NL80211_IFTYPE_UNSPECIFIED.
Said NULL pointer dereference happened when an Accesspoint was started with wpa_supplicant -i mlan0 with this config:
network={
ssid="somessid"
mode=2
frequency=2412
key_mgmt=WPA-PSK WPA-PSK-SHA256
proto=RSN
group=CCMP
pairwise=CCMP
psk="12345678"
}When waiting for the AP to be established, interrupting wpa_supplicant with <ctrl-c> and starting it again this happens:
| Unable to handle kernel NULL pointer dereference at virtual address 0000000000000140 | Mem abort info: | ESR = 0x0000000096000004 | EC = 0x25: DABT (current EL), IL = 32 bits | SET = 0, FnV = 0 | EA = 0, S1PTW = 0 | FSC = 0x04: level 0 translation fault | Data abort info: | ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000 | CM = 0, WnR = 0, TnD = 0, TagAccess = 0 | GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 | user pgtable: 4k pages, 48-bit VAs, pgdp=0000000046d96000 | [0000000000000140] pgd=0000000000000000, p4d=0000000000000000 | Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP | Modules linked in: caam_jr caamhash_desc spidev caamalg_desc crypto_engine authenc libdes mwifiex_sdio +mwifiex crct10dif_ce cdc_acm onboard_usb_hub fsl_imx8_ddr_perf imx8m_ddrc rtc_ds1307 lm75 rtc_snvs +imx_sdma caam imx8mm_thermal spi_imx error imx_cpufreq_dt fuse ip_tables x_tables ipv6 | CPU: 0 PID: 8 Comm: kworker/0:1 Not tainted 6.9.0-00007-g937242013fce-dirty #18 | Hardware name: somemachine (DT) | Workqueue: events sdio_irq_work | pstate: 00000005 (nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) | pc : mwifiex_get_cfp+0xd8/0x15c [mwifiex] | lr : mwifiex_get_cfp+0x34/0x15c [mwifiex] | sp : ffff8000818b3a70 | x29: ffff8000818b3a70 x28: ffff000006bfd8a5 x27: 0000000000000004 | x26: 000000000000002c x25: 0000000000001511 x24: 0000000002e86bc9 | x23: ffff000006bfd996 x22: 0000000000000004 x21: ffff000007bec000 | x20: 000000000000002c x19: 0000000000000000 x18: 0000000000000000 | x17: 000000040044ffff x16: 00500072b5503510 x15: ccc283740681e517 | x14: 0201000101006d15 x13: 0000000002e8ff43 x12: 002c01000000ffb1 | x11: 0100000000000000 x10: 02e8ff43002c0100 x9 : 0000ffb100100157 | x8 : ffff000003d20000 x7 : 00000000000002f1 x6 : 00000000ffffe124 | x5 : 0000000000000001 x4 : 0000000000000003 x3 : 0000000000000000 | x2 : 0000000000000000 x1 : 0001000000011001 x0 : 0000000000000000 | Call trace: | mwifiex_get_cfp+0xd8/0x15c [mwifiex] | mwifiex_parse_single_response_buf+0x1d0/0x504 [mwifiex] | mwifiex_handle_event_ext_scan_report+0x19c/0x2f8 [mwifiex] | mwifiex_process_sta_event+0x298/0xf0c [mwifiex] | mwifiex_process_event+0x110/0x238 [mwifiex] | mwifiex_main_process+0x428/0xa44 [mwifiex] | mwifiex_sdio_interrupt+0x64/0x12c [mwifiex_sdio] | process_sdio_pending_irqs+0x64/0x1b8 | sdio_irq_work+0x4c/0x7c | process_one_work+0x148/0x2a0 | worker_thread+0x2fc/0x40c | kthread+0x110/0x114 | ret_from_fork+0x10/0x20 | Code: a94153f3 a8c37bfd d50323bf d65f03c0 (f940a000) | ---[ end trace 0000000000000000 ]---
--- drivers/net/wireless/marvell/mwifiex/main.h | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/marvell/mwifiex/main.h +3 -0
@@ -1310,6 +1310,9 @@ mwifiex_get_priv_by_id(struct mwifiex_adapter *adapter,for (i =0 ; i < adapter->priv_num; i++) {if (adapter->priv[i]) { +if (adapter->priv[i]->bss_mode ==NL80211_IFTYPE_UNSPECIFIED ) +continue ; +if ((adapter->priv[i]->bss_num == bss_num) && (adapter->priv[i]->bss_type == bss_type))break ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 47/47 i3c: mipi-i3c-hci: Error out instead on BUG_ON() in IBI DMA setup
In reply to Sasha LevinFrom: Jarkko Nikula <[email protected]>
[ Upstream commit 8a2be2f1db268ec735419e53ef04ca039fc027dc ]
Definitely condition dma_get_cache_alignment * defined value > 256 during driver initialization is not reason to BUG_ON(). Turn that to graceful error out with -EINVAL.
--- drivers/i3c/master/mipi-i3c-hci/dma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/i3c/master/mipi-i3c-hci/dma.c +4 -1
@@ -291,7 +291,10 @@ static int hci_dma_init(struct i3c_hci *hci) rh->ibi_chunk_sz =dma_get_cache_alignment (); rh->ibi_chunk_sz *=IBI_CHUNK_CACHELINES ; -BUG_ON (rh->ibi_chunk_sz >256 ); +if (rh->ibi_chunk_sz >256 ) { + ret = -EINVAL ; + goto err_out; + } ibi_status_ring_sz = rh->ibi_status_sz * rh->ibi_status_entries; ibi_data_ring_sz = rh->ibi_chunk_sz * rh->ibi_chunks_total;
Signature · 1 line
2.43.0
Re: [PATCH AUTOSEL 5.15 25/47] PCI: al: Check IORESOURCE_BUS existence during probe
In reply to Sasha LevinHi!
Quoted 9 lines
[ Upstream commit
a9927c2cac6e9831361e43a14d91277818154e6a]If
IORESOURCE_BUSis not provided in Device Tree it will be fabricated inof_pci_parse_bus_range(), so NULL pointer dereference should not happen here.But that's hard to verify, so check for NULL anyway.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
If the NULL can't happen, we should not really apply this to -stable.
Best regards,
Pavel
Quoted 48 lines
+++
b/drivers/pci/controller/dwc/pcie-al.cdrivers/pci/controller/dwc/pcie-al.c +13
-3@@ -242,18 +242,24 @@ static struct pci_ops al_child_pci_ops = { .write = pci_generic_config_write, }; -static void al_pcie_config_prepare (struct al_pcie *pcie) +static int al_pcie_config_prepare (struct al_pcie *pcie) {struct al_pcie_target_bus_cfg *target_bus_cfg;struct pcie_port *pp = &pcie->pci->pp;unsigned int ecam_bus_mask; +struct resource_entry *ft;u32 cfg_control_offset; +struct resource *bus;u8 subordinate_bus;u8 secondary_bus;u32 cfg_control;u32 reg; -struct resource *bus =resource_list_first_type (&pp->bridge->windows,IORESOURCE_BUS )->res; + ft =resource_list_first_type (&pp->bridge->windows,IORESOURCE_BUS ); +if (!ft) +return -ENODEV ; + + bus = ft->res; target_bus_cfg = &pcie->target_bus_cfg; ecam_bus_mask = (pcie->ecam_size >>PCIE_ECAM_BUS_SHIFT ) -1 ;@@ -287,6 +293,8 @@ static void al_pcie_config_prepare(struct al_pcie *pcie)FIELD_PREP (CFG_CONTROL_SEC_BUS_MASK , secondary_bus);al_pcie_controller_writel (pcie, cfg_control_offset, reg); + +return 0 ; }static int al_pcie_host_init (struct pcie_port *pp)@@ -305,7 +313,9 @@ static int al_pcie_host_init(struct pcie_port *pp)if (rc)return rc; -al_pcie_config_prepare (pcie); + rc =al_pcie_config_prepare (pcie); +if (rc) +return rc;return 0 ; }
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany