6.6.130-rc1 review
Subsystems (9)
Greg Kroah-Hartman
maintainerPATCH 257/567 octeontx2-af: devlink health: use retained error fmsg API
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Przemek Kitszel <[email protected]>
[ Upstream commit d8cf03fca3411de8a493dae5e9fcf815a4f0977e ]
Drop unneeded error checking.
devlink_fmsg_*() family of functions is now retaining errors, so there is no need to check for them after each call.
Stable-dep-of: 87f7dff3ec75 ("octeontx2-af: devlink: fix NIX RAS reporter to use RAS interrupt status")
--- .../marvell/octeontx2/af/rvu_devlink.c | 464 +++++------------- 1 file changed, 133 insertions(+), 331 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c +133 -331
@@ -14,26 +14,16 @@#define DRV_NAME "octeontx2-af" -static int rvu_report_pair_start (struct devlink_fmsg *fmsg,const char *name) +static void rvu_report_pair_start (struct devlink_fmsg *fmsg,const char *name) { -int err; - - err =devlink_fmsg_pair_nest_start (fmsg, name); -if (err) -return err; - -return devlink_fmsg_obj_nest_start (fmsg); +devlink_fmsg_pair_nest_start (fmsg, name); +devlink_fmsg_obj_nest_start (fmsg); } -static int rvu_report_pair_end (struct devlink_fmsg *fmsg) +static void rvu_report_pair_end (struct devlink_fmsg *fmsg) { -int err; - - err =devlink_fmsg_obj_nest_end (fmsg); -if (err) -return err; - -return devlink_fmsg_pair_nest_end (fmsg); +devlink_fmsg_obj_nest_end (fmsg); +devlink_fmsg_pair_nest_end (fmsg); } static bool rvu_common_request_irq(struct rvu *rvu, int offset,
@@ -284,175 +274,81 @@ static int rvu_nix_report_show(struct devlink_fmsg *fmsg, void *ctx, {struct rvu_nix_event_ctx *nix_event_context;u64 intr_val; -int err; nix_event_context = ctx;switch (health_reporter) {case NIX_AF_RVU_INTR : intr_val = nix_event_context->nix_af_rvu_int; - err =rvu_report_pair_start (fmsg,"NIX_AF_RVU" ); -if (err) -return err; - err =devlink_fmsg_u64_pair_put (fmsg,"\tNIX RVU Interrupt Reg " , - nix_event_context->nix_af_rvu_int); -if (err) -return err; -if (intr_val &BIT_ULL (0 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tUnmap Slot Error" ); -if (err) -return err; - } - err =rvu_report_pair_end (fmsg); -if (err) -return err; +rvu_report_pair_start (fmsg,"NIX_AF_RVU" ); +devlink_fmsg_u64_pair_put (fmsg,"\tNIX RVU Interrupt Reg " , + nix_event_context->nix_af_rvu_int); +if (intr_val &BIT_ULL (0 )) +devlink_fmsg_string_put (fmsg,"\n\tUnmap Slot Error" ); +rvu_report_pair_end (fmsg);break ;case NIX_AF_RVU_GEN : intr_val = nix_event_context->nix_af_rvu_gen; - err =rvu_report_pair_start (fmsg,"NIX_AF_GENERAL" ); -if (err) -return err; - err =devlink_fmsg_u64_pair_put (fmsg,"\tNIX General Interrupt Reg " , - nix_event_context->nix_af_rvu_gen); -if (err) -return err; -if (intr_val &BIT_ULL (0 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tRx multicast pkt drop" ); -if (err) -return err; - } -if (intr_val &BIT_ULL (1 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tRx mirror pkt drop" ); -if (err) -return err; - } -if (intr_val &BIT_ULL (4 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tSMQ flush done" ); -if (err) -return err; - } - err =rvu_report_pair_end (fmsg); -if (err) -return err; +rvu_report_pair_start (fmsg,"NIX_AF_GENERAL" ); +devlink_fmsg_u64_pair_put (fmsg,"\tNIX General Interrupt Reg " , + nix_event_context->nix_af_rvu_gen); +if (intr_val &BIT_ULL (0 )) +devlink_fmsg_string_put (fmsg,"\n\tRx multicast pkt drop" ); +if (intr_val &BIT_ULL (1 )) +devlink_fmsg_string_put (fmsg,"\n\tRx mirror pkt drop" ); +if (intr_val &BIT_ULL (4 )) +devlink_fmsg_string_put (fmsg,"\n\tSMQ flush done" ); +rvu_report_pair_end (fmsg);break ;case NIX_AF_RVU_ERR : intr_val = nix_event_context->nix_af_rvu_err; - err =rvu_report_pair_start (fmsg,"NIX_AF_ERR" ); -if (err) -return err; - err =devlink_fmsg_u64_pair_put (fmsg,"\tNIX Error Interrupt Reg " , - nix_event_context->nix_af_rvu_err); -if (err) -return err; -if (intr_val &BIT_ULL (14 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tFault on NIX_AQ_INST_S read" ); -if (err) -return err; - } -if (intr_val &BIT_ULL (13 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tFault on NIX_AQ_RES_S write" ); -if (err) -return err; - } -if (intr_val &BIT_ULL (12 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tAQ Doorbell Error" ); -if (err) -return err; - } -if (intr_val &BIT_ULL (6 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tRx on unmapped PF_FUNC" ); -if (err) -return err; - } -if (intr_val &BIT_ULL (5 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tRx multicast replication error" ); -if (err) -return err; - } -if (intr_val &BIT_ULL (4 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tFault on NIX_RX_MCE_S read" ); -if (err) -return err; - } -if (intr_val &BIT_ULL (3 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tFault on multicast WQE read" ); -if (err) -return err; - } -if (intr_val &BIT_ULL (2 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tFault on mirror WQE read" ); -if (err) -return err; - } -if (intr_val &BIT_ULL (1 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tFault on mirror pkt write" ); -if (err) -return err; - } -if (intr_val &BIT_ULL (0 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tFault on multicast pkt write" ); -if (err) -return err; - } - err =rvu_report_pair_end (fmsg); -if (err) -return err; +rvu_report_pair_start (fmsg,"NIX_AF_ERR" ); +devlink_fmsg_u64_pair_put (fmsg,"\tNIX Error Interrupt Reg " , + nix_event_context->nix_af_rvu_err); +if (intr_val &BIT_ULL (14 )) +devlink_fmsg_string_put (fmsg,"\n\tFault on NIX_AQ_INST_S read" ); +if (intr_val &BIT_ULL (13 )) +devlink_fmsg_string_put (fmsg,"\n\tFault on NIX_AQ_RES_S write" ); +if (intr_val &BIT_ULL (12 )) +devlink_fmsg_string_put (fmsg,"\n\tAQ Doorbell Error" ); +if (intr_val &BIT_ULL (6 )) +devlink_fmsg_string_put (fmsg,"\n\tRx on unmapped PF_FUNC" ); +if (intr_val &BIT_ULL (5 )) +devlink_fmsg_string_put (fmsg,"\n\tRx multicast replication error" ); +if (intr_val &BIT_ULL (4 )) +devlink_fmsg_string_put (fmsg,"\n\tFault on NIX_RX_MCE_S read" ); +if (intr_val &BIT_ULL (3 )) +devlink_fmsg_string_put (fmsg,"\n\tFault on multicast WQE read" ); +if (intr_val &BIT_ULL (2 )) +devlink_fmsg_string_put (fmsg,"\n\tFault on mirror WQE read" ); +if (intr_val &BIT_ULL (1 )) +devlink_fmsg_string_put (fmsg,"\n\tFault on mirror pkt write" ); +if (intr_val &BIT_ULL (0 )) +devlink_fmsg_string_put (fmsg,"\n\tFault on multicast pkt write" ); +rvu_report_pair_end (fmsg);break ;case NIX_AF_RVU_RAS : intr_val = nix_event_context->nix_af_rvu_err; - err =rvu_report_pair_start (fmsg,"NIX_AF_RAS" ); -if (err) -return err; - err =devlink_fmsg_u64_pair_put (fmsg,"\tNIX RAS Interrupt Reg " , - nix_event_context->nix_af_rvu_err); -if (err) -return err; - err =devlink_fmsg_string_put (fmsg,"\n\tPoison Data on:" ); -if (err) -return err; -if (intr_val &BIT_ULL (34 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tNIX_AQ_INST_S" ); -if (err) -return err; - } -if (intr_val &BIT_ULL (33 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tNIX_AQ_RES_S" ); -if (err) -return err; - } -if (intr_val &BIT_ULL (32 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tHW ctx" ); -if (err) -return err; - } -if (intr_val &BIT_ULL (4 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tPacket from mirror buffer" ); -if (err) -return err; - } -if (intr_val &BIT_ULL (3 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tPacket from multicast buffer" ); - -if (err) -return err; - } -if (intr_val &BIT_ULL (2 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tWQE read from mirror buffer" ); -if (err) -return err; - } -if (intr_val &BIT_ULL (1 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tWQE read from multicast buffer" ); -if (err) -return err; - } -if (intr_val &BIT_ULL (0 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tNIX_RX_MCE_S read" ); -if (err) -return err; - } - err =rvu_report_pair_end (fmsg); -if (err) -return err; +rvu_report_pair_start (fmsg,"NIX_AF_RAS" ); +devlink_fmsg_u64_pair_put (fmsg,"\tNIX RAS Interrupt Reg " , + nix_event_context->nix_af_rvu_err); +devlink_fmsg_string_put (fmsg,"\n\tPoison Data on:" ); +if (intr_val &BIT_ULL (34 )) +devlink_fmsg_string_put (fmsg,"\n\tNIX_AQ_INST_S" ); +if (intr_val &BIT_ULL (33 )) +devlink_fmsg_string_put (fmsg,"\n\tNIX_AQ_RES_S" ); +if (intr_val &BIT_ULL (32 )) +devlink_fmsg_string_put (fmsg,"\n\tHW ctx" ); +if (intr_val &BIT_ULL (4 )) +devlink_fmsg_string_put (fmsg,"\n\tPacket from mirror buffer" ); +if (intr_val &BIT_ULL (3 )) +devlink_fmsg_string_put (fmsg,"\n\tPacket from multicast buffer" ); +if (intr_val &BIT_ULL (2 )) +devlink_fmsg_string_put (fmsg,"\n\tWQE read from mirror buffer" ); +if (intr_val &BIT_ULL (1 )) +devlink_fmsg_string_put (fmsg,"\n\tWQE read from multicast buffer" ); +if (intr_val &BIT_ULL (0 )) +devlink_fmsg_string_put (fmsg,"\n\tNIX_RX_MCE_S read" ); +rvu_report_pair_end (fmsg);break ;default :return -EINVAL ;
@@ -919,181 +815,87 @@ static int rvu_npa_report_show(struct devlink_fmsg *fmsg, void *ctx,struct rvu_npa_event_ctx *npa_event_context;unsigned int alloc_dis, free_dis;u64 intr_val; -int err; npa_event_context = ctx;switch (health_reporter) {case NPA_AF_RVU_GEN : intr_val = npa_event_context->npa_af_rvu_gen; - err =rvu_report_pair_start (fmsg,"NPA_AF_GENERAL" ); -if (err) -return err; - err =devlink_fmsg_u64_pair_put (fmsg,"\tNPA General Interrupt Reg " , - npa_event_context->npa_af_rvu_gen); -if (err) -return err; -if (intr_val &BIT_ULL (32 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tUnmap PF Error" ); -if (err) -return err; - } +rvu_report_pair_start (fmsg,"NPA_AF_GENERAL" ); +devlink_fmsg_u64_pair_put (fmsg,"\tNPA General Interrupt Reg " , + npa_event_context->npa_af_rvu_gen); +if (intr_val &BIT_ULL (32 )) +devlink_fmsg_string_put (fmsg,"\n\tUnmap PF Error" ); free_dis =FIELD_GET (GENMASK (15 ,0 ), intr_val); -if (free_dis &BIT (NPA_INPQ_NIX0_RX )) { - err =devlink_fmsg_string_put (fmsg,"\n\tNIX0: free disabled RX" ); -if (err) -return err; - } -if (free_dis &BIT (NPA_INPQ_NIX0_TX )) { - err =devlink_fmsg_string_put (fmsg,"\n\tNIX0:free disabled TX" ); -if (err) -return err; - } -if (free_dis &BIT (NPA_INPQ_NIX1_RX )) { - err =devlink_fmsg_string_put (fmsg,"\n\tNIX1: free disabled RX" ); -if (err) -return err; - } -if (free_dis &BIT (NPA_INPQ_NIX1_TX )) { - err =devlink_fmsg_string_put (fmsg,"\n\tNIX1:free disabled TX" ); -if (err) -return err; - } -if (free_dis &BIT (NPA_INPQ_SSO )) { - err =devlink_fmsg_string_put (fmsg,"\n\tFree Disabled for SSO" ); -if (err) -return err; - } -if (free_dis &BIT (NPA_INPQ_TIM )) { - err =devlink_fmsg_string_put (fmsg,"\n\tFree Disabled for TIM" ); -if (err) -return err; - } -if (free_dis &BIT (NPA_INPQ_DPI )) { - err =devlink_fmsg_string_put (fmsg,"\n\tFree Disabled for DPI" ); -if (err) -return err; - } -if (free_dis &BIT (NPA_INPQ_AURA_OP )) { - err =devlink_fmsg_string_put (fmsg,"\n\tFree Disabled for AURA" ); -if (err) -return err; - } +if (free_dis &BIT (NPA_INPQ_NIX0_RX )) +devlink_fmsg_string_put (fmsg,"\n\tNIX0: free disabled RX" ); +if (free_dis &BIT (NPA_INPQ_NIX0_TX )) +devlink_fmsg_string_put (fmsg,"\n\tNIX0:free disabled TX" ); +if (free_dis &BIT (NPA_INPQ_NIX1_RX )) +devlink_fmsg_string_put (fmsg,"\n\tNIX1: free disabled RX" ); +if (free_dis &BIT (NPA_INPQ_NIX1_TX )) +devlink_fmsg_string_put (fmsg,"\n\tNIX1:free disabled TX" ); +if (free_dis &BIT (NPA_INPQ_SSO )) +devlink_fmsg_string_put (fmsg,"\n\tFree Disabled for SSO" ); +if (free_dis &BIT (NPA_INPQ_TIM )) +devlink_fmsg_string_put (fmsg,"\n\tFree Disabled for TIM" ); +if (free_dis &BIT (NPA_INPQ_DPI )) +devlink_fmsg_string_put (fmsg,"\n\tFree Disabled for DPI" ); +if (free_dis &BIT (NPA_INPQ_AURA_OP )) +devlink_fmsg_string_put (fmsg,"\n\tFree Disabled for AURA" ); alloc_dis =FIELD_GET (GENMASK (31 ,16 ), intr_val); -if (alloc_dis &BIT (NPA_INPQ_NIX0_RX )) { - err =devlink_fmsg_string_put (fmsg,"\n\tNIX0: alloc disabled RX" ); -if (err) -return err; - } -if (alloc_dis &BIT (NPA_INPQ_NIX0_TX )) { - err =devlink_fmsg_string_put (fmsg,"\n\tNIX0:alloc disabled TX" ); -if (err) -return err; - } -if (alloc_dis &BIT (NPA_INPQ_NIX1_RX )) { - err =devlink_fmsg_string_put (fmsg,"\n\tNIX1: alloc disabled RX" ); -if (err) -return err; - } -if (alloc_dis &BIT (NPA_INPQ_NIX1_TX )) { - err =devlink_fmsg_string_put (fmsg,"\n\tNIX1:alloc disabled TX" ); -if (err) -return err; - } -if (alloc_dis &BIT (NPA_INPQ_SSO )) { - err =devlink_fmsg_string_put (fmsg,"\n\tAlloc Disabled for SSO" ); -if (err) -return err; - } -if (alloc_dis &BIT (NPA_INPQ_TIM )) { - err =devlink_fmsg_string_put (fmsg,"\n\tAlloc Disabled for TIM" ); -if (err) -return err; - } -if (alloc_dis &BIT (NPA_INPQ_DPI )) { - err =devlink_fmsg_string_put (fmsg,"\n\tAlloc Disabled for DPI" ); -if (err) -return err; - } -if (alloc_dis &BIT (NPA_INPQ_AURA_OP )) { - err =devlink_fmsg_string_put (fmsg,"\n\tAlloc Disabled for AURA" ); -if (err) -return err; - } - err =rvu_report_pair_end (fmsg); -if (err) -return err; +if (alloc_dis &BIT (NPA_INPQ_NIX0_RX )) +devlink_fmsg_string_put (fmsg,"\n\tNIX0: alloc disabled RX" ); +if (alloc_dis &BIT (NPA_INPQ_NIX0_TX )) +devlink_fmsg_string_put (fmsg,"\n\tNIX0:alloc disabled TX" ); +if (alloc_dis &BIT (NPA_INPQ_NIX1_RX )) +devlink_fmsg_string_put (fmsg,"\n\tNIX1: alloc disabled RX" ); +if (alloc_dis &BIT (NPA_INPQ_NIX1_TX )) +devlink_fmsg_string_put (fmsg,"\n\tNIX1:alloc disabled TX" ); +if (alloc_dis &BIT (NPA_INPQ_SSO )) +devlink_fmsg_string_put (fmsg,"\n\tAlloc Disabled for SSO" ); +if (alloc_dis &BIT (NPA_INPQ_TIM )) +devlink_fmsg_string_put (fmsg,"\n\tAlloc Disabled for TIM" ); +if (alloc_dis &BIT (NPA_INPQ_DPI )) +devlink_fmsg_string_put (fmsg,"\n\tAlloc Disabled for DPI" ); +if (alloc_dis &BIT (NPA_INPQ_AURA_OP )) +devlink_fmsg_string_put (fmsg,"\n\tAlloc Disabled for AURA" ); + +rvu_report_pair_end (fmsg);break ;case NPA_AF_RVU_ERR : - err =rvu_report_pair_start (fmsg,"NPA_AF_ERR" ); -if (err) -return err; - err =devlink_fmsg_u64_pair_put (fmsg,"\tNPA Error Interrupt Reg " , - npa_event_context->npa_af_rvu_err); -if (err) -return err; - -if (npa_event_context->npa_af_rvu_err &BIT_ULL (14 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tFault on NPA_AQ_INST_S read" ); -if (err) -return err; - } -if (npa_event_context->npa_af_rvu_err &BIT_ULL (13 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tFault on NPA_AQ_RES_S write" ); -if (err) -return err; - } -if (npa_event_context->npa_af_rvu_err &BIT_ULL (12 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tAQ Doorbell Error" ); -if (err) -return err; - } - err =rvu_report_pair_end (fmsg); -if (err) -return err; +rvu_report_pair_start (fmsg,"NPA_AF_ERR" ); +devlink_fmsg_u64_pair_put (fmsg,"\tNPA Error Interrupt Reg " , + npa_event_context->npa_af_rvu_err); +if (npa_event_context->npa_af_rvu_err &BIT_ULL (14 )) +devlink_fmsg_string_put (fmsg,"\n\tFault on NPA_AQ_INST_S read" ); +if (npa_event_context->npa_af_rvu_err &BIT_ULL (13 )) +devlink_fmsg_string_put (fmsg,"\n\tFault on NPA_AQ_RES_S write" ); +if (npa_event_context->npa_af_rvu_err &BIT_ULL (12 )) +devlink_fmsg_string_put (fmsg,"\n\tAQ Doorbell Error" ); +rvu_report_pair_end (fmsg);break ;case NPA_AF_RVU_RAS : - err =rvu_report_pair_start (fmsg,"NPA_AF_RVU_RAS" ); -if (err) -return err; - err =devlink_fmsg_u64_pair_put (fmsg,"\tNPA RAS Interrupt Reg " , - npa_event_context->npa_af_rvu_ras); -if (err) -return err; -if (npa_event_context->npa_af_rvu_ras &BIT_ULL (34 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tPoison data on NPA_AQ_INST_S" ); -if (err) -return err; - } -if (npa_event_context->npa_af_rvu_ras &BIT_ULL (33 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tPoison data on NPA_AQ_RES_S" ); -if (err) -return err; - } -if (npa_event_context->npa_af_rvu_ras &BIT_ULL (32 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tPoison data on HW context" ); -if (err) -return err; - } - err =rvu_report_pair_end (fmsg); -if (err) -return err; +rvu_report_pair_start (fmsg,"NPA_AF_RVU_RAS" ); +devlink_fmsg_u64_pair_put (fmsg,"\tNPA RAS Interrupt Reg " , + npa_event_context->npa_af_rvu_ras); +if (npa_event_context->npa_af_rvu_ras &BIT_ULL (34 )) +devlink_fmsg_string_put (fmsg,"\n\tPoison data on NPA_AQ_INST_S" ); +if (npa_event_context->npa_af_rvu_ras &BIT_ULL (33 )) +devlink_fmsg_string_put (fmsg,"\n\tPoison data on NPA_AQ_RES_S" ); +if (npa_event_context->npa_af_rvu_ras &BIT_ULL (32 )) +devlink_fmsg_string_put (fmsg,"\n\tPoison data on HW context" ); +rvu_report_pair_end (fmsg);break ;case NPA_AF_RVU_INTR : - err =rvu_report_pair_start (fmsg,"NPA_AF_RVU" ); -if (err) -return err; - err =devlink_fmsg_u64_pair_put (fmsg,"\tNPA RVU Interrupt Reg " , - npa_event_context->npa_af_rvu_int); -if (err) -return err; -if (npa_event_context->npa_af_rvu_int &BIT_ULL (0 )) { - err =devlink_fmsg_string_put (fmsg,"\n\tUnmap Slot Error" ); -if (err) -return err; - } -return rvu_report_pair_end (fmsg); +rvu_report_pair_start (fmsg,"NPA_AF_RVU" ); +devlink_fmsg_u64_pair_put (fmsg,"\tNPA RVU Interrupt Reg " , + npa_event_context->npa_af_rvu_int); +if (npa_event_context->npa_af_rvu_int &BIT_ULL (0 )) +devlink_fmsg_string_put (fmsg,"\n\tUnmap Slot Error" ); +rvu_report_pair_end (fmsg); +break ;default :return -EINVAL ; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 258/567 octeontx2-af: devlink: fix NIX RAS reporter to use RAS interrupt status
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alok Tiwari <[email protected]>
[ Upstream commit 87f7dff3ec75b91def0024ebaaf732457f47a63b ]
The NIX RAS health report path uses nix_af_rvu_err when handling the NIX_AF_RVU_RAS case, so the report prints the ERR interrupt status rather than the RAS interrupt status.
Use nix_af_rvu_ras for the NIX_AF_RVU_RAS report.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c +2 -2
@@ -327,10 +327,10 @@ static int rvu_nix_report_show(struct devlink_fmsg *fmsg, void *ctx,rvu_report_pair_end (fmsg);break ;case NIX_AF_RVU_RAS : - intr_val = nix_event_context->nix_af_rvu_err; + intr_val = nix_event_context->nix_af_rvu_ras;rvu_report_pair_start (fmsg,"NIX_AF_RAS" );devlink_fmsg_u64_pair_put (fmsg,"\tNIX RAS Interrupt Reg " , - nix_event_context->nix_af_rvu_err); + nix_event_context->nix_af_rvu_ras);devlink_fmsg_string_put (fmsg,"\n\tPoison Data on:" );if (intr_val &BIT_ULL (34 ))devlink_fmsg_string_put (fmsg,"\n\tNIX_AQ_INST_S" );
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 259/567 usb: gadget: f_mass_storage: Fix potential integer overflow in check_command_size_in_blocks()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Seungjin Bae <[email protected]>
[ Upstream commit 8479891d1f04a8ce55366fe4ca361ccdb96f02e1 ]
The check_command_size_in_blocks() function calculates the data size in bytes by left shifting common->data_size_from_cmnd by the block size (common->curlun->blkbits). However, it does not validate whether this shift operation will cause an integer overflow.
Initially, the block size is set up in fsg_lun_open() , and the common->data_size_from_cmnd is set up in do_scsi_command(). During initialization, there is no integer overflow check for the interaction between two variables.
So if a malicious USB host sends a SCSI READ or WRITE command requesting a large amount of data (common->data_size_from_cmnd), the left shift operation can wrap around. This results in a truncated data size, which can bypass boundary checks and potentially lead to memory corruption or out-of-bounds accesses.
Fix this by using the check_shl_overflow() macro to safely perform the shift and catch any overflows.
--- drivers/usb/gadget/function/f_mass_storage.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/usb/gadget/function/f_mass_storage.c +10 -2
@@ -180,6 +180,7 @@#include <linux/kthread.h> #include <linux/sched/signal.h> #include <linux/limits.h> +#include <linux/overflow.h> #include <linux/pagemap.h> #include <linux/rwsem.h> #include <linux/slab.h>
@@ -1853,8 +1854,15 @@ static int check_command_size_in_blocks(struct fsg_common *common, int cmnd_size, enum data_direction data_dir, unsigned int mask, int needs_medium, const char *name) { - if (common->curlun) - common->data_size_from_cmnd <<= common->curlun->blkbits; + if (common->curlun) { + if (check_shl_overflow(common->data_size_from_cmnd, + common->curlun->blkbits, + &common->data_size_from_cmnd)) { + common->phase_error = 1; +return -EINVAL ; + } + } +return check_command (common, cmnd_size, data_dir, mask, needs_medium, name); }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 260/567 Revert "arm64: dts: qcom: sdm845-oneplus: Mark l14a regulator as boot-on"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit dc62cf0814fa62177bb4ba944c72d9f122568cdc.
The backport applied regulator-boot-on to vreg_l12a_1p8 (ldo12) instead of vreg_l14a_1p88 (ldo14) due to identical surrounding context lines.
--- arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi | 1 - 1 file changed, 1 deletion(-)
arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi +0 -1
@@ -245,7 +245,6 @@ vreg_l12a_1p8: ldo12 { regulator-min-microvolt = <1800000>; regulator-max-microvolt = <1800000>; regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>; - regulator-boot-on; }; vreg_l14a_1p88: ldo14 {
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 261/567 cgroup: fix race between task migration and iteration
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qingye Zhao <[email protected]>
commit 5ee01f1a7343d6a3547b6802ca2d4cdce0edacb1 upstream.
When a task is migrated out of a css_set, cgroup_migrate_add_task() first moves it from cset->tasks to cset->mg_tasks via:
list_move_tail(&task->cg_list, &cset->mg_tasks);
If a css_task_iter currently has it->task_pos pointing to this task, css_set_move_task() calls css_task_iter_skip() to keep the iterator valid. However, since the task has already been moved to ->mg_tasks, the iterator is advanced relative to the mg_tasks list instead of the original tasks list. As a result, remaining tasks on cset->tasks, as well as tasks queued on cset->mg_tasks, can be skipped by iteration.
Fix this by calling css_set_skip_task_iters() before unlinking task->cg_list from cset->tasks. This advances all active iterators to the next task on cset->tasks, so iteration continues correctly even when a task is concurrently being migrated.
This race is hard to hit in practice without instrumentation, but it can be reproduced by artificially slowing down cgroup_procs_show(). For example, on an Android device a temporary /sys/kernel/cgroup/cgroup_test knob can be added to inject a delay into cgroup_procs_show(), and then:
1) Spawn three long-running tasks (PIDs 101, 102, 103).
2) Create a test cgroup and move the tasks into it.
3) Enable a large delay via /sys/kernel/cgroup/cgroup_test.
4) In one shell, read cgroup.procs from the test cgroup.
5) Within the delay window, in another shell migrate PID 102 by writing it to a different cgroup.procs file.
Under this setup, cgroup.procs can intermittently show only PID 101 while skipping PID 103. Once the migration completes, reading the file again shows all tasks as expected.
Note that this change does not allow removing the existing css_set_skip_task_iters() call in css_set_move_task(). The new call in cgroup_migrate_add_task() only handles iterators that are racing with migration while the task is still on cset->tasks. Iterators may also start after the task has been moved to cset->mg_tasks. If we dropped css_set_skip_task_iters() from css_set_move_task(), such iterators could keep task_pos pointing to a migrating task, causing css_task_iter_advance() to malfunction on the destination css_set, up to and including crashes or infinite loops.
The race window between migration and iteration is very small, and css_task_iter is not on a hot path. In the worst case, when an iterator is positioned on the first thread of the migrating process, cgroup_migrate_add_task() may have to skip multiple tasks via css_set_skip_task_iters(). However, this only happens when migration and iteration actually race, so the performance impact is negligible compared to the correctness fix provided here.
--- kernel/cgroup/cgroup.c | 1 + 1 file changed, 1 insertion(+)
kernel/cgroup/cgroup.c +1 -0
@@ -2457,6 +2457,7 @@ static void cgroup_migrate_add_task(stru mgctx->tset.nr_tasks++; +css_set_skip_task_iters (cset, task);list_move_tail (&task->cg_list, &cset->mg_tasks);if (list_empty (&cset->mg_node)) list_add_tail(&cset->mg_node,
Greg Kroah-Hartman
maintainerPATCH 262/567 ALSA: pcm: fix use-after-free on linked stream runtime in snd_pcm_drain()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mehul Rao <[email protected]>
commit 9b1dbd69ba6f8f8c69bc7b77c2ce3b9c6ed05ba6 upstream.
In the drain loop, the local variable 'runtime' is reassigned to a linked stream's runtime (runtime = s->runtime at line 2157). After releasing the stream lock at line 2169, the code accesses runtime->no_period_wakeup, runtime->rate, and runtime->buffer_size (lines 2170-2178) — all referencing the linked stream's runtime without any lock or refcount protecting its lifetime.
A concurrent close() on the linked stream's fd triggers snd_pcm_release_substream() → snd_pcm_drop() → pcm_release_private() → snd_pcm_unlink() → snd_pcm_detach_substream() → kfree(runtime). No synchronization prevents kfree(runtime) from completing while the drain path dereferences the stale pointer.
Fix by caching the needed runtime fields (no_period_wakeup, rate, buffer_size) into local variables while still holding the stream lock, and using the cached values after the lock is released.
--- sound/core/pcm_native.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
sound/core/pcm_native.c +16 -3
@@ -2148,6 +2148,10 @@ static int snd_pcm_drain(struct snd_pcm_for (;;) {long tout;struct snd_pcm_runtime *to_check; +unsigned int drain_rate; +snd_pcm_uframes_t drain_bufsz; +bool drain_no_period_wakeup; +if (signal_pending (current)) { result = -ERESTARTSYS ;break ;
@@ -2167,16 +2171,25 @@ static int snd_pcm_drain(struct snd_pcm_snd_pcm_group_unref (group, substream);if (!to_check)break ;/* all drained */ +/* +* Cache the runtime fields needed after unlock. +* A concurrent close() on the linked stream may free +* its runtime via snd_pcm_detach_substream() once we +* release the stream lock below. +*/ + drain_no_period_wakeup = to_check->no_period_wakeup; + drain_rate = to_check->rate; + drain_bufsz = to_check->buffer_size;init_waitqueue_entry (&wait, current);set_current_state (TASK_INTERRUPTIBLE );add_wait_queue (&to_check->sleep, &wait);snd_pcm_stream_unlock_irq (substream); -if (runtime->no_period_wakeup) +if (drain_no_period_wakeup) tout =MAX_SCHEDULE_TIMEOUT ;else { tout =100 ; -if (runtime->rate) { -long t = runtime->buffer_size *1100 / runtime->rate; +if (drain_rate) { +long t = drain_bufsz *1100 / drain_rate; tout =max (t, tout); } tout =msecs_to_jiffies (tout);
Greg Kroah-Hartman
maintainerPATCH 263/567 ALSA: usb-audio: Check endpoint numbers at parsing Scarlett2 mixer interfaces
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit df1d8abf36ca3681c21a6809eaa9a1e01ef897a6 upstream.
The Scarlett2 mixer quirk in USB-audio driver may hit a NULL dereference when a malformed USB descriptor is passed, since it assumes the presence of an endpoint in the parsed interface in scarlett2_find_fc_interface(), as reported by fuzzer.
For avoiding the NULL dereference, just add the sanity check of bNumEndpoints and skip the invalid interface.
--- sound/usb/mixer_scarlett2.c | 2 ++ 1 file changed, 2 insertions(+)
sound/usb/mixer_scarlett2.c +2 -0
@@ -3898,6 +3898,8 @@ static int scarlett2_find_fc_interface(sif (desc->bInterfaceClass !=255 )continue ; +if (desc->bNumEndpoints <1 ) +continue ; epd =get_endpoint (intf->altsetting,0 ); private->bInterfaceNumber = desc->bInterfaceNumber;
Greg Kroah-Hartman
maintainerPATCH 264/567 net: usb: lan78xx: fix silent drop of packets with checksum errors
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleksij Rempel <[email protected]>
commit e4f774a0cc955ce762aec91c66915a6e15087ab7 upstream.
Do not drop packets with checksum errors at the USB driver level; pass them to the network stack.
Previously, the driver dropped all packets where the 'Receive Error Detected' (RED) bit was set, regardless of the specific error type. This caused packets with only IP or TCP/UDP checksum errors to be dropped before reaching the kernel, preventing the network stack from accounting for them or performing software fallback.
Add a mask for hard hardware errors to safely drop genuinely corrupt frames, while allowing checksum-errored frames to pass with their ip_summed field explicitly set to CHECKSUM_NONE.
--- drivers/net/usb/lan78xx.c | 4 +++- drivers/net/usb/lan78xx.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/net/usb/lan78xx.c +3 -1
@@ -3537,6 +3537,7 @@ static void lan78xx_rx_csum_offload(stru*/ if (!(dev->net->features &NETIF_F_RXCSUM ) ||unlikely (rx_cmd_a &RX_CMD_A_ICSM_ ) || +unlikely (rx_cmd_a &RX_CMD_A_CSE_MASK_ ) || ((rx_cmd_a &RX_CMD_A_FVTG_ ) && !(dev->net->features &NETIF_F_HW_VLAN_CTAG_RX ))) { skb->ip_summed =CHECKSUM_NONE ;
@@ -3609,7 +3610,8 @@ static int lan78xx_rx(struct lan78xx_netreturn 0 ; } -if (unlikely (rx_cmd_a &RX_CMD_A_RED_ )) { +if (unlikely (rx_cmd_a &RX_CMD_A_RED_ ) && + (rx_cmd_a &RX_CMD_A_RX_HARD_ERRS_MASK_ )) {netif_dbg (dev, rx_err, dev->net,"Error rx_cmd_a=0x%08x" , rx_cmd_a); }else {
drivers/net/usb/lan78xx.h +3 -0
@@ -74,6 +74,9 @@#define RX_CMD_A_ICSM_ (0x00004000)#define RX_CMD_A_LEN_MASK_ (0x00003FFF) +#define RX_CMD_A_RX_HARD_ERRS_MASK_ \ + (RX_CMD_A_RX_ERRS_MASK_ & ~RX_CMD_A_CSE_MASK_) +/* Rx Command B */ #define RX_CMD_B_CSUM_SHIFT_ (16)#define RX_CMD_B_CSUM_MASK_ (0xFFFF0000)
Greg Kroah-Hartman
maintainerPATCH 265/567 net: usb: lan78xx: fix TX byte statistics for small packets
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleksij Rempel <[email protected]>
commit 50988747c30df47b73b787f234f746027cb7ec6c upstream.
Account for hardware auto-padding in TX byte counters to reflect actual wire traffic.
The LAN7850 hardware automatically pads undersized frames to the minimum Ethernet frame length (ETH_ZLEN, 60 bytes). However, the driver tracks the network statistics based on the unpadded socket buffer length. This results in the tx_bytes counter under-reporting the actual physical bytes placed on the Ethernet wire for small packets (like short ARP or ICMP requests).
Use max_t() to ensure the transmission statistics accurately account for the hardware-generated padding.
--- drivers/net/usb/lan78xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/lan78xx.c +1 -1
@@ -3886,7 +3886,7 @@ static struct skb_data *lan78xx_tx_buf_f } tx_data += len; - entry->length += len; + entry->length += max_t(unsigned int, len, ETH_ZLEN); entry->num_of_packet +=skb_shinfo (skb)->gso_segs ?:1 ;dev_kfree_skb_any (skb);
Greg Kroah-Hartman
maintainerPATCH 266/567 net: usb: lan78xx: skip LTM configuration for LAN7850
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleksij Rempel <[email protected]>
commit d9cc0e440f0664f6f3e2c26e39ab9dd5f3badba7 upstream.
Do not configure Latency Tolerance Messaging (LTM) on USB 2.0 hardware.
The LAN7850 is a High-Speed (USB 2.0) only device and does not support SuperSpeed features like LTM. Currently, the driver unconditionally attempts to configure LTM registers during initialization. On the LAN7850, these registers do not exist, resulting in writes to invalid or undocumented memory space.
This issue was identified during a port to the regmap API with strict register validation enabled. While no functional issues or crashes have been observed from these invalid writes, bypassing LTM initialization on the LAN7850 ensures the driver strictly adheres to the hardware's valid register map.
--- drivers/net/usb/lan78xx.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/usb/lan78xx.c +4 -0
@@ -2672,6 +2672,10 @@ static void lan78xx_init_ltm(struct lan7u32 buf;u32 regs[6 ] = {0 }; +/* LAN7850 is USB 2.0 and does not support LTM */ +if (dev->chipid ==ID_REV_CHIP_ID_7850_ ) +return ; + ret =lan78xx_read_reg (dev,USB_CFG1 , &buf);if (buf &USB_CFG1_LTM_ENABLE_ ) {u8 temp[2 ];
Greg Kroah-Hartman
maintainerPATCH 267/567 ASoC: amd: yc: Add DMI quirk for ASUS EXPERTBOOK PM1503CDA
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Heng <[email protected]>
commit 325291b20f8a6f14b9c82edbf5d12e4e71f6adaa upstream.
Add a DMI quirk for the ASUS EXPERTBOOK PM1503CDA fixing the issue where the internal microphone was not detected.
--- sound/soc/amd/yc/acp6x-mach.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/amd/yc/acp6x-mach.c +7 -0
@@ -703,6 +703,13 @@ static const struct dmi_system_id yc_acp DMI_MATCH(DMI_PRODUCT_NAME, "ASUS EXPERTBOOK BM1503CDA"), } }, + { + .driver_data = &acp6x_card, + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_BOARD_NAME, "PM1503CDA"), + } + }, {} };
Greg Kroah-Hartman
maintainerPATCH 268/567 KVM: SVM: Initialize AVIC VMCB fields if AVIC is enabled with in-kernel APIC
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 3989a6d036c8ec82c0de3614bed23a1dacd45de5 upstream.
Initialize all per-vCPU AVIC control fields in the VMCB if AVIC is enabled in KVM and the VM has an in-kernel local APIC, i.e. if it's _possible_ the vCPU could activate AVIC at any point in its lifecycle. Configuring the VMCB if and only if AVIC is active "works" purely because of optimizations in kvm_create_lapic() to speculatively set apicv_active if AVIC is enabled *and* to defer updates until the first KVM_RUN. In quotes because KVM likely won't do the right thing if kvm_apicv_activated() is false, i.e. if a vCPU is created while APICv is inhibited at the VM level for whatever reason. E.g. if the inhibit is *removed* before KVM_REQ_APICV_UPDATE is handled in KVM_RUN, then __kvm_vcpu_update_apicv() will elide calls to vendor code due to seeing "apicv_active == activate".
Cleaning up the initialization code will also allow fixing a bug where KVM incorrectly leaves CR8 interception enabled when AVIC is activated without creating a mess with respect to whether AVIC is activated or not.
--- arch/x86/kvm/svm/avic.c | 2 +- arch/x86/kvm/svm/svm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/kvm/svm/avic.c +1 -1
@@ -253,7 +253,7 @@ void avic_init_vmcb(struct vcpu_svm *svm vmcb->control.avic_physical_id = ppa &AVIC_HPA_MASK ; vmcb->control.avic_vapic_bar =APIC_DEFAULT_PHYS_BASE &VMCB_AVIC_APIC_BAR_MASK ; -if (kvm_apicv_activated (svm->vcpu.kvm)) +if (kvm_vcpu_apicv_active (&svm->vcpu))avic_activate_vmcb (svm);else avic_deactivate_vmcb (svm);
arch/x86/kvm/svm/svm.c +1 -1
@@ -1375,7 +1375,7 @@ static void init_vmcb(struct kvm_vcpu *vif (boot_cpu_has (X86_FEATURE_V_SPEC_CTRL ))set_msr_interception (vcpu, svm->msrpm,MSR_IA32_SPEC_CTRL ,1 ,1 ); -if (kvm_vcpu_apicv_active (vcpu)) +if (enable_apicv &&irqchip_in_kernel (vcpu->kvm))avic_init_vmcb (svm, vmcb);if (vnmi)
Greg Kroah-Hartman
maintainerPATCH 269/567 USB: add QUIRK_NO_BOS for video capture several devices
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: A1RM4X <[email protected]>
commit 93cd0d664661f58f7e7bed7373714ab2ace41734 upstream.
Several USB capture devices also need the USB_QUIRK_NO_BOS set for them to work properly, odds are they are all the same chip inside, just different vendor/product ids.
This fixes up:
- ASUS TUF 4K PRO
- Avermedia Live Gamer Ultra 2.1 (GC553G2)
- UGREEN 35871
to now run at full speed (10 Gbps/4K 60 fps mode.)
--- drivers/usb/core/quirks.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/usb/core/quirks.c +9 -0
@@ -377,6 +377,9 @@ static const struct usb_device_id usb_qu/* SanDisk Extreme 55AE */ { USB_DEVICE(0x0781, 0x55ae), .driver_info = USB_QUIRK_NO_LPM }, + /* Avermedia Live Gamer Ultra 2.1 (GC553G2) - BOS descriptor fetch hangs at SuperSpeed Plus */ + { USB_DEVICE(0x07ca, 0x2553), .driver_info = USB_QUIRK_NO_BOS }, + /* Realforce 87U Keyboard */ { USB_DEVICE(0x0853, 0x011b), .driver_info = USB_QUIRK_NO_LPM },
@@ -434,6 +437,9 @@ static const struct usb_device_id usb_qu { USB_DEVICE(0x0b05, 0x17e0), .driver_info = USB_QUIRK_IGNORE_REMOTE_WAKEUP }, + /* ASUS TUF 4K PRO - BOS descriptor fetch hangs at SuperSpeed Plus */ + { USB_DEVICE(0x0b05, 0x1ab9), .driver_info = USB_QUIRK_NO_BOS }, + /* Realtek Semiconductor Corp. Mass Storage Device (Multicard Reader)*/ { USB_DEVICE(0x0bda, 0x0151), .driver_info = USB_QUIRK_CONFIG_INTF_STRINGS },
@@ -562,6 +568,9 @@ static const struct usb_device_id usb_qu { USB_DEVICE(0x2386, 0x350e), .driver_info = USB_QUIRK_NO_LPM }, + /* UGREEN 35871 - BOS descriptor fetch hangs at SuperSpeed Plus */ + { USB_DEVICE(0x2b89, 0x5871), .driver_info = USB_QUIRK_NO_BOS }, + /* APTIV AUTOMOTIVE HUB */ { USB_DEVICE(0x2c48, 0x0132), .driver_info = USB_QUIRK_SHORT_SET_ADDRESS_REQ_TIMEOUT },
Greg Kroah-Hartman
maintainerPATCH 270/567 usb/core/quirks: Add Huawei ME906S-device to wakeup quirk
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoffer Sandberg <[email protected]>
commit 0326ff28d56b4fa202de36ffc8462a354f383a64 upstream.
Similar to other Huawei LTE modules using this quirk, this version with another vid/pid suffers from spurious wakeups.
Setting the quirk fixes the issue for this device as well.
--- drivers/usb/core/quirks.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/core/quirks.c +4 -0
@@ -208,6 +208,10 @@ static const struct usb_device_id usb_qu/* HP v222w 16GB Mini USB Drive */ { USB_DEVICE(0x03f0, 0x3f40), .driver_info = USB_QUIRK_DELAY_INIT }, + /* Huawei 4G LTE module ME906S */ + { USB_DEVICE(0x03f0, 0xa31d), .driver_info = + USB_QUIRK_DISCONNECT_SUSPEND }, + /* Creative SB Audigy 2 NX */ { USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME },
Greg Kroah-Hartman
maintainerPATCH 271/567 USB: ezcap401 needs USB_QUIRK_NO_BOS to function on 10gbs usb speed
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vyacheslav Vahnenko <[email protected]>
commit d0d9b1f4f5391e6a00cee81d73ed2e8f98446d5f upstream.
Add USB_QUIRK_NO_BOS for ezcap401 capture card, without it dmesg will show "unable to get BOS descriptor or descriptor too short" and "unable to read config index 0 descriptor/start: -71" errors and device will not able to work at full speed at 10gbs
--- drivers/usb/core/quirks.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/core/quirks.c +3 -0
@@ -585,6 +585,9 @@ static const struct usb_device_id usb_qu/* Alcor Link AK9563 SC Reader used in 2022 Lenovo ThinkPads */ { USB_DEVICE(0x2ce3, 0x9563), .driver_info = USB_QUIRK_NO_LPM }, + /* ezcap401 - BOS descriptor fetch hangs at SuperSpeed Plus */ + { USB_DEVICE(0x32ed, 0x0401), .driver_info = USB_QUIRK_NO_BOS }, + /* DELL USB GEN2 */ { USB_DEVICE(0x413c, 0xb062), .driver_info = USB_QUIRK_NO_LPM | USB_QUIRK_RESET_RESUME },
Greg Kroah-Hartman
maintainerPATCH 272/567 usb: xhci: Fix memory leak in xhci_disable_slot()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zilin Guan <[email protected]>
commit c1c8550e70401159184130a1afc6261db01fc0ce upstream.
xhci_alloc_command() allocates a command structure and, when the second argument is true, also allocates a completion structure. Currently, the error handling path in xhci_disable_slot() only frees the command structure using kfree(), causing the completion structure to leak.
Use xhci_free_command() instead of kfree(). xhci_free_command() correctly frees both the command structure and the associated completion structure. Since the command structure is allocated with zero-initialization, command->in_ctx is NULL and will not be erroneously freed by xhci_free_command().
This bug was found using an experimental static analysis tool we are developing. The tool is based on the LLVM framework and is specifically designed to detect memory management issues. It is currently under active development and not yet publicly available, but we plan to open-source it after our research is published.
The bug was originally detected on v6.13-rc1 using our static analysis tool, and we have verified that the issue persists in the latest mainline kernel.
We performed build testing on x86_64 with allyesconfig using GCC=11.4.0. Since triggering these error paths in xhci_disable_slot() requires specific hardware conditions or abnormal state, we were unable to construct a test case to reliably trigger these specific error paths at runtime.
--- drivers/usb/host/xhci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/host/xhci.c +2 -2
@@ -3939,7 +3939,7 @@ int xhci_disable_slot(struct xhci_hcd *xif (state ==0xffffffff || (xhci->xhc_state &XHCI_STATE_DYING ) || (xhci->xhc_state &XHCI_STATE_HALTED )) {spin_unlock_irqrestore (&xhci->lock, flags); -kfree (command); +xhci_free_command (xhci, command);return -ENODEV ; }
@@ -3947,7 +3947,7 @@ int xhci_disable_slot(struct xhci_hcd *x slot_id);if (ret) {spin_unlock_irqrestore (&xhci->lock, flags); -kfree (command); +xhci_free_command (xhci, command);return ret; }xhci_ring_cmd_db (xhci);
Greg Kroah-Hartman
maintainerPATCH 273/567 usb: xhci: Prevent interrupt storm on host controller error (HCE)
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dayu Jiang <[email protected]>
commit d6d5febd12452b7fd951fdd15c3ec262f01901a4 upstream.
The xHCI controller reports a Host Controller Error (HCE) in UAS Storage Device plug/unplug scenarios on Android devices. HCE is checked in xhci_irq() function and causes an interrupt storm (since the interrupt isn’t cleared), leading to severe system-level faults.
When the xHC controller reports HCE in the interrupt handler, the driver only logs a warning and assumes xHC activity will stop as stated in xHCI specification. An interrupt storm does however continue on some hosts even after HCE, and only ceases after manually disabling xHC interrupt and stopping the controller by calling xhci_halt().
Add xhci_halt() to xhci_irq() function where STS_HCE status is checked, mirroring the existing error handling pattern used for STS_FATAL errors.
This only fixes the interrupt storm. Proper HCE recovery requires resetting and re-initializing the xHC.
--- drivers/usb/host/xhci-ring.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/host/xhci-ring.c +1 -0
@@ -3219,6 +3219,7 @@ irqreturn_t xhci_irq(struct usb_hcd *hcdif (status &STS_HCE ) {xhci_warn (xhci,"WARNING: Host Controller Error\n" ); +xhci_halt (xhci); goto out; }
Greg Kroah-Hartman
maintainerPATCH 274/567 usb: yurex: fix race in probe
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit 7a875c09899ba0404844abfd8f0d54cdc481c151 upstream.
The bbu member of the descriptor must be set to the value standing for uninitialized values before the URB whose completion handler sets bbu is submitted. Otherwise there is a window during which probing can overwrite already retrieved data.
--- drivers/usb/misc/yurex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/misc/yurex.c +1 -1
@@ -272,6 +272,7 @@ static int yurex_probe(struct usb_interf dev->int_buffer,YUREX_BUF_SIZE , yurex_interrupt, dev, 1); dev->urb->transfer_flags |=URB_NO_TRANSFER_DMA_MAP ; + dev->bbu =-1 ;if (usb_submit_urb (dev->urb,GFP_KERNEL )) { retval = -EIO ;dev_err (&interface->dev,"Could not submitting URB\n" );
@@ -280,7 +281,6 @@ static int yurex_probe(struct usb_interf/* save our data pointer in this interface device */ usb_set_intfdata (interface, dev); - dev->bbu =-1 ;/* we can register the device now, as it is ready */ retval =usb_register_dev (interface, &yurex_class);
Greg Kroah-Hartman
maintainerPATCH 275/567 usb: dwc3: pci: add support for the Intel Nova Lake -H
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heikki Krogerus <[email protected]>
commit 17ab4d4078e22be7fd8fd6fc710c15c085a4cb1b upstream.
This patch adds the necessary PCI ID for Intel Nova Lake -H devices.
--- drivers/usb/dwc3/dwc3-pci.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/dwc3/dwc3-pci.c +2 -0
@@ -56,6 +56,7 @@#define PCI_DEVICE_ID_INTEL_CNPH 0xa36e#define PCI_DEVICE_ID_INTEL_CNPV 0xa3b0#define PCI_DEVICE_ID_INTEL_RPL 0xa70e +#define PCI_DEVICE_ID_INTEL_NVLH 0xd37f#define PCI_DEVICE_ID_INTEL_PTLH 0xe332#define PCI_DEVICE_ID_INTEL_PTLH_PCH 0xe37e#define PCI_DEVICE_ID_INTEL_PTLU 0xe432
@@ -448,6 +449,7 @@ static const struct pci_device_id dwc3_p { PCI_DEVICE_DATA(INTEL, CNPH, &dwc3_pci_intel_swnode) }, { PCI_DEVICE_DATA(INTEL, CNPV, &dwc3_pci_intel_swnode) }, { PCI_DEVICE_DATA(INTEL, RPL, &dwc3_pci_intel_swnode) }, + { PCI_DEVICE_DATA(INTEL, NVLH, &dwc3_pci_intel_swnode) }, { PCI_DEVICE_DATA(INTEL, PTLH, &dwc3_pci_intel_swnode) }, { PCI_DEVICE_DATA(INTEL, PTLH_PCH, &dwc3_pci_intel_swnode) }, { PCI_DEVICE_DATA(INTEL, PTLU, &dwc3_pci_intel_swnode) },
Greg Kroah-Hartman
maintainerPATCH 276/567 usb: misc: uss720: properly clean up reference in uss720_probe()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit 45dba8011efac11a2f360383221b541f5ea53ce5 upstream.
If get_1284_register() fails, the usb device reference count is incorrect and needs to be properly dropped before returning. That will happen when the kref is dropped in the call to destroy_priv(), so jump to that error path instead of returning directly.
--- drivers/usb/misc/uss720.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/misc/uss720.c +1 -1
@@ -733,7 +733,7 @@ static int uss720_probe(struct usb_inter ret =get_1284_register (pp,0 , ®,GFP_KERNEL );dev_dbg (&intf->dev,"reg: %7ph\n" , priv->reg);if (ret <0 ) -return ret; + goto probe_abort; ret =usb_find_last_int_in_endpoint (interface, &epd);if (!ret) {
Greg Kroah-Hartman
maintainerPATCH 277/567 usb: core: dont power off roothub PHYs if phy_set_mode() fails
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabor Juhos <[email protected]>
commit e293015ba76eb96ce4ebed7e3b2cb1a7d319f3e9 upstream.
Remove the error path from the usb_phy_roothub_set_mode() function. The code is clearly wrong, because phy_set_mode() calls can't be balanced with phy_power_off() calls.
Additionally, the usb_phy_roothub_set_mode() function is called only from usb_add_hcd() before it powers on the PHYs, so powering off those makes no sense anyway.
Presumably, the code is copy-pasted from the phy_power_on() function without adjusting the error handling.
--- drivers/usb/core/phy.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/usb/core/phy.c +1 -7
@@ -138,16 +138,10 @@ int usb_phy_roothub_set_mode(struct usb_list_for_each_entry (roothub_entry, head, list) { err =phy_set_mode (roothub_entry->phy, mode);if (err) - goto err_out; +return err; }return 0 ; - -err_out: -list_for_each_entry_continue_reverse (roothub_entry, head, list) -phy_power_off (roothub_entry->phy); - -return err; }EXPORT_SYMBOL_GPL (usb_phy_roothub_set_mode);
Greg Kroah-Hartman
maintainerPATCH 278/567 usb: cdc-acm: Restore CAP_BRK functionnality to CH343
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
commit 14ae24cba291bddfdc296bbcbfd00cd09d0498ef upstream.
The CH343 USB/serial adapter is as buggy as it is popular (very). One of its quirks is that despite being capable of signalling a BREAK condition, it doesn't advertise it.
This used to work nonetheless until 66aad7d8d3ec5 ("usb: cdc-acm:
return correct error code on unsupported break") applied some reasonable restrictions, preventing breaks from being emitted on devices that do not advertise CAP_BRK.
Add a quirk for this particular device, so that breaks can still be produced on some of my machines attached to my console server.
--- drivers/usb/class/cdc-acm.c | 5 +++++ drivers/usb/class/cdc-acm.h | 1 + 2 files changed, 6 insertions(+)
drivers/usb/class/cdc-acm.c +5 -0
@@ -1379,6 +1379,8 @@ made_compressed_probe: acm->ctrl_caps = h.usb_cdc_acm_descriptor->bmCapabilities;if (quirks &NO_CAP_LINE ) acm->ctrl_caps &= ~USB_CDC_CAP_LINE ; +if (quirks &MISSING_CAP_BRK ) + acm->ctrl_caps |=USB_CDC_CAP_BRK ; acm->ctrlsize = ctrlsize; acm->readsize = readsize; acm->rx_buflimit = num_rx_buf;
@@ -2002,6 +2004,9 @@ static const struct usb_device_id acm_id .driver_info = IGNORE_DEVICE, }, +/* CH343 supports CAP_BRK, but doesn't advertise it */ + { USB_DEVICE(0x1a86, 0x55d3), .driver_info = MISSING_CAP_BRK, }, + /* control interfaces without any protocol set */ { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, USB_CDC_PROTO_NONE) },
drivers/usb/class/cdc-acm.h +1 -0
@@ -113,3 +113,4 @@ struct acm {#define CLEAR_HALT_CONDITIONS BIT(5)#define SEND_ZERO_PACKET BIT(6)#define DISABLE_ECHO BIT(7) +#define MISSING_CAP_BRK BIT(8)
Greg Kroah-Hartman
maintainerPATCH 279/567 usb: roles: get usb role switch from parent only for usb-b-connector
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Yang <[email protected]>
commit 8345b1539faa49fcf9c9439c3cbd97dac6eca171 upstream.
usb_role_switch_is_parent() was walking up to the parent node and checking for the "usb-role-switch" property regardless of the type of the passed fwnode. This could cause unrelated device nodes to be probed as potential role switch parent, leading to spurious matches and "-EPROBE_DEFER" being returned infinitely.
Till now only Type-B connector node will have a parent node which may present "usb-role-switch" property and register the role switch device. For Type-C connector node, its parent node will always be a Type-C chip device which will never register the role switch device. However, it may still present a non-boolean "usb-role-switch = <&usb_controller>" property for historical compatibility.
So restrict the helper to only operate on Type-B connector when attempting to get the role switch from parent node.
--- drivers/usb/roles/class.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/roles/class.c +6 -1
@@ -110,9 +110,14 @@ static void *usb_role_switch_match(conststatic struct usb_role_switch *usb_role_switch_is_parent (struct fwnode_handle *fwnode) { -struct fwnode_handle *parent =fwnode_get_parent (fwnode); +struct fwnode_handle *parent;struct device *dev; +if (!fwnode_device_is_compatible (fwnode,"usb-b-connector" )) +return NULL ; + + parent =fwnode_get_parent (fwnode); +if (!fwnode_property_present (parent,"usb-role-switch" )) {fwnode_handle_put (parent);return NULL ;
Greg Kroah-Hartman
maintainerPATCH 280/567 USB: usbcore: Introduce usb_bulk_msg_killable()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 416909962e7cdf29fd01ac523c953f37708df93d upstream.
The synchronous message API in usbcore (usb_control_msg(), usb_bulk_msg(), and so on) uses uninterruptible waits. However, drivers may call these routines in the context of a user thread, which means it ought to be possible to at least kill them.
For this reason, introduce a new usb_bulk_msg_killable() function which behaves the same as usb_bulk_msg() except for using wait_for_completion_killable_timeout() instead of wait_for_completion_timeout(). The same can be done later for usb_control_msg() later on, if it turns out to be needed.
--- drivers/usb/core/message.c | 79 +++++++++++++++++++++++++++++++++++++++------ include/linux/usb.h | 5 +- 2 files changed, 72 insertions(+), 12 deletions(-)
drivers/usb/core/message.c +69 -10
@@ -42,16 +42,17 @@ static void usb_api_blocking_completion(/* -* Starts urb and waits for completion or timeout. Note that this call -* is NOT interruptible. Many device driver i/o requests should be -* interruptible and therefore these drivers should implement their -* own interruptible routines. +* Starts urb and waits for completion or timeout. +* Whether or not the wait is killable depends on the flag passed in. +* For example, compare usb_bulk_msg() and usb_bulk_msg_killable(). */ -static int usb_start_wait_urb (struct urb *urb,int timeout,int *actual_length) +static int usb_start_wait_urb (struct urb *urb,int timeout,int *actual_length, +bool killable) {struct api_context ctx;unsigned long expire;int retval; +long rc;init_completion (&ctx.done); urb->context = &ctx;
@@ -61,12 +62,21 @@ static int usb_start_wait_urb(struct urb goto out; expire = timeout ?msecs_to_jiffies (timeout) :MAX_SCHEDULE_TIMEOUT ; -if (!wait_for_completion_timeout (&ctx.done, expire)) { +if (killable) + rc =wait_for_completion_killable_timeout (&ctx.done, expire); +else + rc =wait_for_completion_timeout (&ctx.done, expire); +if (rc <=0 ) {usb_kill_urb (urb); - retval = (ctx.status == -ENOENT ? -ETIMEDOUT : ctx.status); +if (ctx.status != -ENOENT ) + retval = ctx.status; +else if (rc ==0 ) + retval = -ETIMEDOUT ; +else + retval = rc; dev_dbg(&urb->dev->dev, - "%s timed out on ep%d%s len=%u/%u\n", + "%s timed out or killed on ep%d%s len=%u/%u\n", current->comm, usb_endpoint_num(&urb->ep->desc), usb_urb_dir_in(urb) ? "in" : "out",
@@ -100,7 +110,7 @@ static int usb_internal_control_msg(struusb_fill_control_urb (urb, usb_dev, pipe, (unsigned char *)cmd, data, len, usb_api_blocking_completion,NULL ); - retv =usb_start_wait_urb (urb, timeout, &length); + retv =usb_start_wait_urb (urb, timeout, &length, false);if (retv <0 )return retv;else
@@ -385,10 +395,59 @@ int usb_bulk_msg(struct usb_device *usb_usb_fill_bulk_urb (urb, usb_dev, pipe, data, len, usb_api_blocking_completion,NULL ); -return usb_start_wait_urb (urb, timeout, actual_length); +return usb_start_wait_urb (urb, timeout, actual_length, false); }EXPORT_SYMBOL_GPL (usb_bulk_msg); +/** +* usb_bulk_msg_killable - Builds a bulk urb, sends it off and waits for completion in a killable state +* @usb_dev: pointer to the usb device to send the message to +* @pipe: endpoint "pipe" to send the message to +* @data: pointer to the data to send +* @len: length in bytes of the data to send +* @actual_length: pointer to a location to put the actual length transferred +* in bytes +* @timeout: time in msecs to wait for the message to complete before +* timing out (if 0 the wait is forever) +* +* Context: task context, might sleep. +* +* This function is just like usb_blk_msg() except that it waits in a +* killable state. +* +* Return: +* If successful, 0. Otherwise a negative error number. The number of actual +* bytes transferred will be stored in the @actual_length parameter. +* +*/ +int usb_bulk_msg_killable (struct usb_device *usb_dev,unsigned int pipe, +void *data,int len,int *actual_length,int timeout) +{ +struct urb *urb; +struct usb_host_endpoint *ep; + + ep =usb_pipe_endpoint (usb_dev, pipe); +if (!ep || len <0 ) +return -EINVAL ; + + urb =usb_alloc_urb (0 ,GFP_KERNEL ); +if (!urb) +return -ENOMEM ; + +if ((ep->desc.bmAttributes &USB_ENDPOINT_XFERTYPE_MASK ) == +USB_ENDPOINT_XFER_INT ) { + pipe = (pipe & ~(3 <<30 )) | (PIPE_INTERRUPT <<30 ); +usb_fill_int_urb (urb, usb_dev, pipe, data, len, + usb_api_blocking_completion,NULL , + ep->desc.bInterval); + }else +usb_fill_bulk_urb (urb, usb_dev, pipe, data, len, + usb_api_blocking_completion,NULL ); + +return usb_start_wait_urb (urb, timeout, actual_length, true); +} +EXPORT_SYMBOL_GPL (usb_bulk_msg_killable); +/*-------------------------------------------------------------------*/ static void sg_clean (struct usb_sg_request *io)
include/linux/usb.h +3 -2
@@ -1849,8 +1849,9 @@ extern int usb_control_msg(struct usb_deextern int usb_interrupt_msg (struct usb_device *usb_dev,unsigned int pipe,void *data,int len,int *actual_length,int timeout);extern int usb_bulk_msg (struct usb_device *usb_dev,unsigned int pipe, -void *data,int len,int *actual_length, -int timeout); +void *data,int len,int *actual_length,int timeout); +extern int usb_bulk_msg_killable (struct usb_device *usb_dev,unsigned int pipe, +void *data,int len,int *actual_length,int timeout);/* wrappers around usb_control_msg() for the most common standard requests */ int usb_control_msg_send(struct usb_device *dev, __u8 endpoint, __u8 request,
Greg Kroah-Hartman
maintainerPATCH 281/567 USB: usbtmc: Use usb_bulk_msg_killable() with user-specified timeouts
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 7784caa413a89487dd14dd5c41db8753483b2acb upstream.
The usbtmc driver accepts timeout values specified by the user in an ioctl command, and uses these timeouts for some usb_bulk_msg() calls. Since the user can specify arbitrarily long timeouts and usb_bulk_msg() uses unkillable waits, call usb_bulk_msg_killable() instead to avoid the possibility of the user hanging a kernel thread indefinitely.
--- drivers/usb/class/usbtmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/class/usbtmc.c +3 -3
@@ -727,7 +727,7 @@ static int usbtmc488_ioctl_trigger(struc buffer[1 ] = data->bTag; buffer[2 ] = ~data->bTag; - retval = usb_bulk_msg(data->usb_dev, + retval = usb_bulk_msg_killable(data->usb_dev, usb_sndbulkpipe(data->usb_dev, data->bulk_out), buffer, USBTMC_HEADER_SIZE,
@@ -1347,7 +1347,7 @@ static int send_request_dev_dep_msg_in(s buffer[11 ] =0 ;/* Reserved */ /* Send bulk URB */ - retval = usb_bulk_msg(data->usb_dev, + retval = usb_bulk_msg_killable(data->usb_dev, usb_sndbulkpipe(data->usb_dev, data->bulk_out), buffer, USBTMC_HEADER_SIZE,
@@ -1419,7 +1419,7 @@ static ssize_t usbtmc_read(struct file * actual =0 ;/* Send bulk URB */ - retval = usb_bulk_msg(data->usb_dev, + retval = usb_bulk_msg_killable(data->usb_dev, usb_rcvbulkpipe(data->usb_dev, data->bulk_in), buffer, bufsize, &actual,
Greg Kroah-Hartman
maintainerPATCH 282/567 USB: core: Limit the length of unkillable synchronous timeouts
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 1015c27a5e1a63efae2b18a9901494474b4d1dc3 upstream.
The usb_control_msg(), usb_bulk_msg(), and usb_interrupt_msg() APIs in usbcore allow unlimited timeout durations. And since they use uninterruptible waits, this leaves open the possibility of hanging a task for an indefinitely long time, with no way to kill it short of unplugging the target device.
To prevent this sort of problem, enforce a maximum limit on the length of these unkillable timeouts. The limit chosen here, somewhat arbitrarily, is 60 seconds. On many systems (although not all) this is short enough to avoid triggering the kernel's hung-task detector.
In addition, clear up the ambiguity of negative timeout values by treating them the same as 0, i.e., using the maximum allowed timeout.
--- drivers/usb/core/message.c | 27 +++++++++++++-------------- include/linux/usb.h | 3 +++ 2 files changed, 16 insertions(+), 14 deletions(-)
drivers/usb/core/message.c +13 -14
@@ -45,6 +45,8 @@ static void usb_api_blocking_completion(* Starts urb and waits for completion or timeout. * Whether or not the wait is killable depends on the flag passed in. * For example, compare usb_bulk_msg() and usb_bulk_msg_killable(). +* +* For non-killable waits, we enforce a maximum limit on the timeout value. */ static int usb_start_wait_urb (struct urb *urb,int timeout,int *actual_length,bool killable)
@@ -61,7 +63,9 @@ static int usb_start_wait_urb(struct urbif (unlikely (retval)) goto out; - expire = timeout ?msecs_to_jiffies (timeout) :MAX_SCHEDULE_TIMEOUT ; +if (!killable && (timeout <=0 || timeout >USB_MAX_SYNCHRONOUS_TIMEOUT )) + timeout =USB_MAX_SYNCHRONOUS_TIMEOUT ; + expire = (timeout >0 ) ?msecs_to_jiffies (timeout) :MAX_SCHEDULE_TIMEOUT ;if (killable) rc =wait_for_completion_killable_timeout (&ctx.done, expire);else
@@ -127,8 +131,7 @@ static int usb_internal_control_msg(stru* @index: USB message index value * @data: pointer to the data to send * @size: length in bytes of the data to send -* @timeout: time in msecs to wait for the message to complete before timing -* out (if 0 the wait is forever) +* @timeout: time in msecs to wait for the message to complete before timing out * * Context: task context, might sleep. *
@@ -183,8 +186,7 @@ EXPORT_SYMBOL_GPL(usb_control_msg);* @index: USB message index value * @driver_data: pointer to the data to send * @size: length in bytes of the data to send -* @timeout: time in msecs to wait for the message to complete before timing -* out (if 0 the wait is forever) +* @timeout: time in msecs to wait for the message to complete before timing out * @memflags: the flags for memory allocation for buffers * * Context: !in_interrupt ()
@@ -242,8 +244,7 @@ EXPORT_SYMBOL_GPL(usb_control_msg_send);* @index: USB message index value * @driver_data: pointer to the data to be filled in by the message * @size: length in bytes of the data to be received -* @timeout: time in msecs to wait for the message to complete before timing -* out (if 0 the wait is forever) +* @timeout: time in msecs to wait for the message to complete before timing out * @memflags: the flags for memory allocation for buffers * * Context: !in_interrupt ()
@@ -314,8 +315,7 @@ EXPORT_SYMBOL_GPL(usb_control_msg_recv);* @len: length in bytes of the data to send * @actual_length: pointer to a location to put the actual length transferred * in bytes -* @timeout: time in msecs to wait for the message to complete before -* timing out (if 0 the wait is forever) +* @timeout: time in msecs to wait for the message to complete before timing out * * Context: task context, might sleep. *
@@ -347,8 +347,7 @@ EXPORT_SYMBOL_GPL(usb_interrupt_msg);* @len: length in bytes of the data to send * @actual_length: pointer to a location to put the actual length transferred * in bytes -* @timeout: time in msecs to wait for the message to complete before -* timing out (if 0 the wait is forever) +* @timeout: time in msecs to wait for the message to complete before timing out * * Context: task context, might sleep. *
@@ -408,12 +407,12 @@ EXPORT_SYMBOL_GPL(usb_bulk_msg);* @actual_length: pointer to a location to put the actual length transferred * in bytes * @timeout: time in msecs to wait for the message to complete before -* timing out (if 0 the wait is forever) +* timing out (if <= 0, the wait is as long as possible) * * Context: task context, might sleep. * -* This function is just like usb_blk_msg() except that it waits in a -* killable state. +* This function is just like usb_blk_msg(), except that it waits in a +* killable state and there is no limit on the timeout length. * * Return: * If successful, 0. Otherwise a negative error number. The number of actual
include/linux/usb.h +3 -0
@@ -1843,6 +1843,9 @@ void usb_buffer_unmap_sg(const struct us* SYNCHRONOUS CALL SUPPORT * *-------------------------------------------------------------------*/ +/* Maximum value allowed for timeout in synchronous routines below */ +#define USB_MAX_SYNCHRONOUS_TIMEOUT 60000/* ms */ +extern int usb_control_msg (struct usb_device *dev,unsigned int pipe,__u8 request,__u8 requesttype,__u16 value,__u16 index,void *data,__u16 size,int timeout);
Greg Kroah-Hartman
maintainerPATCH 283/567 usb: class: cdc-wdm: fix reordering issue in read code path
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit 8df672bfe3ec2268c2636584202755898e547173 upstream.
Quoting the bug report:
Due to compiler optimization or CPU out-of-order execution, the desc->length update can be reordered before the memmove. If this happens, wdm_read() can see the new length and call copy_to_user() on uninitialized memory. This also violates LKMM data race rules [1].
Fix it by using WRITE_ONCE and memory barriers.
--- drivers/usb/class/cdc-wdm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/class/cdc-wdm.c +3 -1
@@ -225,7 +225,8 @@ static void wdm_in_callback(struct urb */* we may already be in overflow */ if (!test_bit (WDM_OVERFLOW , &desc->flags)) {memmove (desc->ubuf + desc->length, desc->inbuf, length); - desc->length += length; +smp_wmb ();/* against wdm_read() */ +WRITE_ONCE (desc->length, desc->length + length); } } skip_error:
@@ -533,6 +534,7 @@ static ssize_t wdm_readreturn -ERESTARTSYS ; cntr =READ_ONCE (desc->length); +smp_rmb ();/* against wdm_in_callback() */ if (cntr ==0 ) { desc->read =0 ; retry:
Greg Kroah-Hartman
maintainerPATCH 284/567 usb: renesas_usbhs: fix use-after-free in ISR during device removal
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
commit 3cbc242b88c607f55da3d0d0d336b49bf1e20412 upstream.
In usbhs_remove(), the driver frees resources (including the pipe array) while the interrupt handler (usbhs_interrupt) is still registered. If an interrupt fires after usbhs_pipe_remove() but before the driver is fully unbound, the ISR may access freed memory, causing a use-after-free.
Fix this by calling devm_free_irq() before freeing resources. This ensures the interrupt handler is both disabled and synchronized (waits for any running ISR to complete) before usbhs_pipe_remove() is called.
--- drivers/usb/renesas_usbhs/common.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/usb/renesas_usbhs/common.c +9 -0
@@ -800,6 +800,15 @@ static void usbhs_remove(struct platformusbhs_platform_call (priv, hardware_exit, pdev);reset_control_assert (priv->rsts); + +/* +* Explicitly free the IRQ to ensure the interrupt handler is +* disabled and synchronized before freeing resources. +* devm_free_irq() calls free_irq() which waits for any running +* ISR to complete, preventing UAF. +*/ +devm_free_irq (&pdev->dev, priv->irq, priv); +usbhs_mod_remove (priv);usbhs_fifo_remove (priv);usbhs_pipe_remove (priv);
Greg Kroah-Hartman
maintainerPATCH 285/567 usb: mdc800: handle signal and read racing
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit 2d6d260e9a3576256fe9ef6d1f7930c9ec348723 upstream.
If a signal arrives after a read has partially completed, we need to return the number of bytes read. -EINTR is correct only if that number is zero.
--- drivers/usb/image/mdc800.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/image/mdc800.c +1 -1
@@ -708,7 +708,7 @@ static ssize_t mdc800_device_read (strucif (signal_pending (current)) {mutex_unlock (&mdc800->io_lock); -return -EINTR ; +return len == left ? -EINTR : len-left; } sts=left > (mdc800->out_count-mdc800->out_ptr)?mdc800->out_count-mdc800->out_ptr:left;
Greg Kroah-Hartman
maintainerPATCH 286/567 usb: image: mdc800: kill download URB on timeout
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ziyi Guo <[email protected]>
commit 1be3b77de4eb89af8ae2fd6610546be778e25589 upstream.
mdc800_device_read() submits download_urb and waits for completion. If the timeout fires and the device has not responded, the function returns without killing the URB, leaving it active.
A subsequent read() resubmits the same URB while it is still in-flight, triggering the WARN in usb_submit_urb():
"URB submitted while active"
Check the return value of wait_event_timeout() and kill the URB if it indicates timeout, ensuring the URB is complete before its status is inspected or the URB is resubmitted.
Similar to
- commit 372c93131998 ("USB: yurex: fix control-URB timeout handling")
- commit b98d5000c505 ("media: rc: iguanair: handle timeouts")
--- drivers/usb/image/mdc800.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/image/mdc800.c +3 -1
@@ -731,9 +731,11 @@ static ssize_t mdc800_device_read (strucmutex_unlock (&mdc800->io_lock);return len-left; } -wait_event_timeout (mdc800->download_wait, + retval =wait_event_timeout (mdc800->download_wait, mdc800->downloaded,msecs_to_jiffies (TO_DOWNLOAD_GET_READY )); +if (!retval) +usb_kill_urb (mdc800->download_urb); mdc800->downloaded =0 ;if (mdc800->download_urb->status !=0 ) {
Greg Kroah-Hartman
maintainerPATCH 287/567 mm/tracing: rss_stat: ensure curr is false from kthread context
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kalesh Singh <[email protected]>
commit 079c24d5690262e83ee476e2a548e416f3237511 upstream.
The rss_stat trace event allows userspace tools, like Perfetto [1], to inspect per-process RSS metric changes over time.
The curr field was introduced to rss_stat in commit e4dcad204d3a ("rss_stat: add support to detect RSS updates of external mm"). Its intent is to indicate whether the RSS update is for the mm_struct of the current execution context; and is set to false when operating on a remote mm_struct (e.g., via kswapd or a direct reclaimer).
However, an issue arises when a kernel thread temporarily adopts a user process's mm_struct. Kernel threads do not have their own mm_struct and normally have current->mm set to NULL. To operate on user memory, they can "borrow" a memory context using kthread_use_mm(), which sets current->mm to the user process's mm.
This can be observed, for example, in the USB Function Filesystem (FFS) driver. The ffs_user_copy_worker() handles AIO completions and uses kthread_use_mm() to copy data to a user-space buffer. If a page fault occurs during this copy, the fault handler executes in the kthread's context.
At this point, current is the kthread, but current->mm points to the user process's mm. Since the rss_stat event (from the page fault) is for that same mm, the condition current->mm == mm becomes true, causing curr to be incorrectly set to true when the trace event is emitted.
This is misleading because it suggests the mm belongs to the kthread, confusing userspace tools that track per-process RSS changes and corrupting their mm_id-to-process association.
Fix this by ensuring curr is always false when the trace event is emitted from a kthread context by checking for the PF_KTHREAD flag.
--- include/trace/events/kmem.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
include/trace/events/kmem.h +7 -1
@@ -359,7 +359,13 @@ TRACE_EVENT(rss_stat,TP_fast_assign ( __entry->mm_id = mm_ptr_to_hash(mm); - __entry->curr = !!(current->mm == mm); +/* +* curr is true if the mm matches the current task's mm_struct. +* Since kthreads (PF_KTHREAD) have no mm_struct of their own +* but can borrow one via kthread_use_mm(), we must filter them +* out to avoid incorrectly attributing the RSS update to them. +*/ + __entry->curr = current->mm == mm && !(current->flags &PF_KTHREAD ); __entry->member = member; __entry->size = (percpu_counter_sum_positive (&mm->rss_stat[member]) <<PAGE_SHIFT );
Greg Kroah-Hartman
maintainerPATCH 288/567 mmc: mmci: Fix device_node reference leak in of_get_dml_pipe_index()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
commit af12e64ae0661546e8b4f5d30d55c5f53a11efe7 upstream.
When calling of_parse_phandle_with_args(), the caller is responsible to call of_node_put() to release the reference of device node. In of_get_dml_pipe_index(), it does not release the reference.
--- drivers/mmc/host/mmci_qcom_dml.c | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/host/mmci_qcom_dml.c +1 -0
@@ -109,6 +109,7 @@ static int of_get_dml_pipe_index(struct &dma_spec))return -ENODEV ; +of_node_put (dma_spec.np);if (dma_spec.args_count)return dma_spec.args[0 ];
Greg Kroah-Hartman
maintainerPATCH 289/567 mm/kfence: disable KFENCE upon KASAN HW tags enablement
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Potapenko <[email protected]>
commit 09833d99db36d74456a4d13eb29c32d56ff8f2b6 upstream.
KFENCE does not currently support KASAN hardware tags. As a result, the two features are incompatible when enabled simultaneously.
Given that MTE provides deterministic protection and KFENCE is a sampling-based debugging tool, prioritize the stronger hardware protections. Disable KFENCE initialization and free the pre-allocated pool if KASAN hardware tags are detected to ensure the system maintains the security guarantees provided by MTE.
--- mm/kfence/core.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
mm/kfence/core.c +15 -0
@@ -13,6 +13,7 @@#include <linux/hash.h> #include <linux/irq_work.h> #include <linux/jhash.h> +#include <linux/kasan-enabled.h> #include <linux/kcsan-checks.h> #include <linux/kfence.h> #include <linux/kmemleak.h>
@@ -862,6 +863,20 @@ void __init kfence_alloc_pool_and_metadareturn ;/* +* If KASAN hardware tags are enabled, disable KFENCE, because it +* does not support MTE yet. +*/ +if (kasan_hw_tags_enabled ()) { +pr_info ("disabled as KASAN HW tags are enabled\n" ); +if (__kfence_pool) { +memblock_free (__kfence_pool,KFENCE_POOL_SIZE ); + __kfence_pool =NULL ; + } + kfence_sample_interval =0 ; +return ; + } + +/* * If the pool has already been initialized by arch, there is no need to * re-allocate the memory pool. */
Greg Kroah-Hartman
maintainerPATCH 290/567 mmc: core: Avoid bitfield RMW for claim/retune flags
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Penghe Geng <[email protected]>
commit 901084c51a0a8fb42a3f37d2e9c62083c495f824 upstream.
Move claimed and retune control flags out of the bitfield word to avoid unrelated RMW side effects in asynchronous contexts.
The host->claimed bit shared a word with retune flags. Writes to claimed in __mmc_claim_host() or retune_now in mmc_mq_queue_rq() can overwrite other bits when concurrent updates happen in other contexts, triggering spurious WARN_ON(!host->claimed). Convert claimed, can_retune, retune_now and retune_paused to bool to remove shared-word coupling.
--- include/linux/mmc/host.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
include/linux/mmc/host.h +5 -4
@@ -446,14 +446,12 @@ struct mmc_host {struct mmc_ios ios;/* current io bus settings */ +bool claimed;/* host exclusively claimed */ +/* group bitfields together to minimize padding */ unsigned int use_spi_crc:1; - unsigned int claimed:1; /* host exclusively claimed */ unsigned int doing_init_tune:1; /* initial tuning in progress */ - unsigned int can_retune:1; /* re-tuning can be used */ unsigned int doing_retune:1; /* re-tuning in progress */ - unsigned int retune_now:1; /* do re-tuning at next req */ - unsigned int retune_paused:1; /* re-tuning is temporarily disabled */ unsigned int retune_crc_disable:1; /* don't trigger retune upon crc */ unsigned int can_dma_map_merge:1; /* merging can be used */ unsigned int vqmmc_enabled:1; /* vqmmc regulator is enabled */
@@ -461,6 +459,9 @@ struct mmc_host {int rescan_disable;/* disable card detection */ int rescan_entered;/* used with nonremovable devices */ +bool can_retune;/* re-tuning can be used */ +bool retune_now;/* do re-tuning at next req */ +bool retune_paused;/* re-tuning is temporarily disabled */ int need_retune;/* re-tuning is needed */ int hold_retune;/* hold off re-tuning */ unsigned int retune_period;/* re-tuning period in secs */
Greg Kroah-Hartman
maintainerPATCH 291/567 ASoC: qcom: qdsp6: Fix q6apm remove ordering during ADSP stop and start
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ravi Hothi <[email protected]>
commit d6db827b430bdcca3976cebca7bd69cca03cde2c upstream.
During ADSP stop and start, the kernel crashes due to the order in which ASoC components are removed.
On ADSP stop, the q6apm-audio .remove callback unloads topology and removes PCM runtimes during ASoC teardown. This deletes the RTDs that contain the q6apm DAI components before their removal pass runs, leaving those components still linked to the card and causing crashes on the next rebind.
Fix this by ensuring that all dependent (child) components are removed first, and the q6apm component is removed last.
[ 48.105720] Unable to handle kernel NULL pointer dereference at virtual address 00000000000000d0 [ 48.114763] Mem abort info: [ 48.117650] ESR = 0x0000000096000004 [ 48.121526] EC = 0x25: DABT (current EL), IL = 32 bits [ 48.127010] SET = 0, FnV = 0 [ 48.130172] EA = 0, S1PTW = 0 [ 48.133415] FSC = 0x04: level 0 translation fault [ 48.138446] Data abort info: [ 48.141422] ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000 [ 48.147079] CM = 0, WnR = 0, TnD = 0, TagAccess = 0 [ 48.152354] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 [ 48.157859] user pgtable: 4k pages, 48-bit VAs, pgdp=00000001173cf000 [ 48.164517] [00000000000000d0] pgd=0000000000000000, p4d=0000000000000000 [ 48.171530] Internal error: Oops: 0000000096000004 [#1] SMP [ 48.177348] Modules linked in: q6prm_clocks q6apm_lpass_dais q6apm_dai snd_q6dsp_common q6prm snd_q6apm 8021q garp mrp stp llc snd_soc_hdmi_codec apr pdr_interface phy_qcom_edp fastrpc qcom_pd_mapper rpmsg_ctrl qrtr_smd rpmsg_char qcom_pdr_msg qcom_iris v4l2_mem2mem videobuf2_dma_contig ath11k_pci msm ubwc_config at24 ath11k videobuf2_memops mac80211 ocmem videobuf2_v4l2 libarc4 drm_gpuvm mhi qrtr videodev drm_exec snd_soc_sc8280xp gpu_sched videobuf2_common nvmem_qcom_spmi_sdam snd_soc_qcom_sdw drm_dp_aux_bus qcom_q6v5_pas qcom_spmi_temp_alarm snd_soc_qcom_common rtc_pm8xxx qcom_pon drm_display_helper cec qcom_pil_info qcom_stats soundwire_bus drm_client_lib mc dispcc0_sa8775p videocc_sa8775p qcom_q6v5 camcc_sa8775p snd_soc_dmic phy_qcom_sgmii_eth snd_soc_max98357a i2c_qcom_geni snd_soc_core dwmac_qcom_ethqos llcc_qcom icc_bwmon qcom_sysmon snd_compress qcom_refgen_regulator coresight_stm stmmac_platform snd_pcm_dmaengine qcom_common coresight_tmc stmmac coresight_replicator qcom_glink_smem coresight_cti stm_core [ 48.177444] coresight_funnel snd_pcm ufs_qcom phy_qcom_qmp_usb gpi phy_qcom_snps_femto_v2 coresight phy_qcom_qmp_ufs qcom_wdt gpucc_sa8775p pcs_xpcs mdt_loader qcom_ice icc_osm_l3 qmi_helpers snd_timer snd soundcore display_connector qcom_rng nvmem_reboot_mode drm_kms_helper phy_qcom_qmp_pcie sha256 cfg80211 rfkill socinfo fuse drm backlight ipv6 [ 48.301059] CPU: 2 UID: 0 PID: 293 Comm: kworker/u32:2 Not tainted 6.19.0-rc6-dirty #10 PREEMPT [ 48.310081] Hardware name: Qualcomm Technologies, Inc. Lemans EVK (DT) [ 48.316782] Workqueue: pdr_notifier_wq pdr_notifier_work [pdr_interface] [ 48.323672] pstate: 20400005 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 48.330825] pc : mutex_lock+0xc/0x54 [ 48.334514] lr : soc_dapm_shutdown_dapm+0x44/0x174 [snd_soc_core] [ 48.340794] sp : ffff800084ddb7b0 [ 48.344207] x29: ffff800084ddb7b0 x28: ffff00009cd9cf30 x27: ffff00009cd9cc00 [ 48.351544] x26: ffff000099610190 x25: ffffa31d2f19c810 x24: ffffa31d2f185098 [ 48.358869] x23: ffff800084ddb7f8 x22: 0000000000000000 x21: 00000000000000d0 [ 48.366198] x20: ffff00009ba6c338 x19: ffff00009ba6c338 x18: 00000000ffffffff [ 48.373528] x17: 000000040044ffff x16: ffffa31d4ae6dca8 x15: 072007740775076f [ 48.380853] x14: 0765076d07690774 x13: 00313a323a656369 x12: 767265733a637673 [ 48.388182] x11: 00000000000003f9 x10: ffffa31d4c7dea98 x9 : 0000000000000001 [ 48.395519] x8 : ffff00009a2aadc0 x7 : 0000000000000003 x6 : 0000000000000000 [ 48.402854] x5 : 0000000000000000 x4 : 0000000000000028 x3 : ffff000ef397a698 [ 48.410180] x2 : ffff00009a2aadc0 x1 : 0000000000000000 x0 : 00000000000000d0 [ 48.417506] Call trace: [ 48.420025] mutex_lock+0xc/0x54 (P) [ 48.423712] snd_soc_dapm_shutdown+0x44/0xbc [snd_soc_core] [ 48.429447] soc_cleanup_card_resources+0x30/0x2c0 [snd_soc_core] [ 48.435719] snd_soc_bind_card+0x4dc/0xcc0 [snd_soc_core] [ 48.441278] snd_soc_add_component+0x27c/0x2c8 [snd_soc_core] [ 48.447192] snd_soc_register_component+0x9c/0xf4 [snd_soc_core] [ 48.453371] devm_snd_soc_register_component+0x64/0xc4 [snd_soc_core] [ 48.459994] apm_probe+0xb4/0x110 [snd_q6apm] [ 48.464479] apr_device_probe+0x24/0x40 [apr] [ 48.468964] really_probe+0xbc/0x298 [ 48.472651] __driver_probe_device+0x78/0x12c [ 48.477132] driver_probe_device+0x40/0x160 [ 48.481435] __device_attach_driver+0xb8/0x134 [ 48.486011] bus_for_each_drv+0x80/0xdc [ 48.489964] __device_attach+0xa8/0x1b0 [ 48.493916] device_initial_probe+0x50/0x54 [ 48.498219] bus_probe_device+0x38/0xa0 [ 48.502170] device_add+0x590/0x760 [ 48.505761] device_register+0x20/0x30 [ 48.509623] of_register_apr_devices+0x1d8/0x318 [apr] [ 48.514905] apr_pd_status+0x2c/0x54 [apr] [ 48.519114] pdr_notifier_work+0x8c/0xe0 [pdr_interface] [ 48.524570] process_one_work+0x150/0x294 [ 48.528692] worker_thread+0x2d8/0x3d8 [ 48.532551] kthread+0x130/0x204 [ 48.535874] ret_from_fork+0x10/0x20 [ 48.539559] Code: d65f03c0 d5384102 d503201f d2800001 (c8e17c02) [ 48.545823] ---[ end trace 0000000000000000 ]---
--- sound/soc/qcom/qdsp6/q6apm-dai.c | 1 + sound/soc/qcom/qdsp6/q6apm-lpass-dais.c | 1 + sound/soc/qcom/qdsp6/q6apm.c | 1 + 3 files changed, 3 insertions(+)
sound/soc/qcom/qdsp6/q6apm-dai.c +1 -0
@@ -841,6 +841,7 @@ static const struct snd_soc_component_dr .ack = q6apm_dai_ack, .compress_ops = &q6apm_dai_compress_ops, .use_dai_pcm_id = true, + .remove_order = SND_SOC_COMP_ORDER_EARLY, };static int q6apm_dai_probe (struct platform_device *pdev)
sound/soc/qcom/qdsp6/q6apm-lpass-dais.c +1 -0
@@ -272,6 +272,7 @@ static const struct snd_soc_component_dr .of_xlate_dai_name = q6dsp_audio_ports_of_xlate_dai_name, .be_pcm_base = AUDIOREACH_BE_PCM_BASE, .use_dai_pcm_id = true, + .remove_order = SND_SOC_COMP_ORDER_FIRST, };static int q6apm_lpass_dai_dev_probe (struct platform_device *pdev)
sound/soc/qcom/qdsp6/q6apm.c +1 -0
@@ -732,6 +732,7 @@ static const struct snd_soc_component_dr .name = APM_AUDIO_DRV_NAME, .probe = q6apm_audio_probe, .remove = q6apm_audio_remove, + .remove_order = SND_SOC_COMP_ORDER_LAST, };static int apm_probe (gpr_device_t *gdev)
Greg Kroah-Hartman
maintainerPATCH 292/567 tipc: fix divide-by-zero in tipc_sk_filter_connect()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mehul Rao <[email protected]>
commit 6c5a9baa15de240e747263aba435a0951da8d8d2 upstream.
A user can set conn_timeout to any value via setsockopt(TIPC_CONN_TIMEOUT), including values less than 4. When a SYN is rejected with TIPC_ERR_OVERLOAD and the retry path in tipc_sk_filter_connect() executes:
delay %= (tsk->conn_timeout / 4);
If conn_timeout is in the range [0, 3], the integer division yields 0, and the modulo operation triggers a divide-by-zero exception, causing a kernel oops/panic.
Fix this by clamping conn_timeout to a minimum of 4 at the point of use in tipc_sk_filter_connect().
Oops: divide error: 0000 [#1] SMP KASAN NOPTI CPU: 0 UID: 0 PID: 119 Comm: poc-F144 Not tainted 7.0.0-rc2+ RIP: 0010:tipc_sk_filter_rcv (net/tipc/socket.c:2236 net/tipc/socket.c:2362) Call Trace: tipc_sk_backlog_rcv (include/linux/instrumented.h:82 include/linux/atomic/atomic-instrumented.h:32 include/net/sock.h:2357 net/tipc/socket.c:2406) __release_sock (include/net/sock.h:1185 net/core/sock.c:3213) release_sock (net/core/sock.c:3797) tipc_connect (net/tipc/socket.c:2570) __sys_connect (include/linux/file.h:62 include/linux/file.h:83 net/socket.c:2098)
--- net/tipc/socket.c | 2 ++ 1 file changed, 2 insertions(+)
net/tipc/socket.c +2 -0
@@ -2238,6 +2238,8 @@ static bool tipc_sk_filter_connect(strucif (skb_queue_empty (&sk->sk_write_queue))break ;get_random_bytes (&delay,2 ); +if (tsk->conn_timeout <4 ) + tsk->conn_timeout =4 ; delay %= (tsk->conn_timeout /4 ); delay =msecs_to_jiffies (delay +100 );sk_reset_timer (sk, &sk->sk_timer, jiffies + delay);
Greg Kroah-Hartman
maintainerPATCH 293/567 kprobes: avoid crash when rmmod/insmod after ftrace killed
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <[email protected]>
commit e113f0b46d19626ec15388bcb91432c9a4fd6261 upstream.
After we hit ftrace is killed by some errors, the kernel crash if we remove modules in which kprobe probes.
BUG: unable to handle page fault for address: fffffbfff805000d PGD 817fcc067 P4D 817fcc067 PUD 817fc8067 PMD 101555067 PTE 0 Oops: Oops: 0000 [#1] SMP KASAN PTI CPU: 4 UID: 0 PID: 2012 Comm: rmmod Tainted: G W OE Tainted: [W]=WARN, [O]=OOT_MODULE, [E]=UNSIGNED_MODULE RIP: 0010:kprobes_module_callback+0x89/0x790 RSP: 0018:ffff88812e157d30 EFLAGS: 00010a02 RAX: 1ffffffff805000d RBX: dffffc0000000000 RCX: ffffffff86a8de90 RDX: ffffed1025c2af9b RSI: 0000000000000008 RDI: ffffffffc0280068 RBP: 0000000000000000 R08: 0000000000000001 R09: ffffed1025c2af9a R10: ffff88812e157cd7 R11: 205d323130325420 R12: 0000000000000002 R13: ffffffffc0290488 R14: 0000000000000002 R15: ffffffffc0280040 FS: 00007fbc450dd740(0000) GS:ffff888420331000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: fffffbfff805000d CR3: 000000010f624000 CR4: 00000000000006f0 Call Trace: <TASK> notifier_call_chain+0xc6/0x280 blocking_notifier_call_chain+0x60/0x90 __do_sys_delete_module.constprop.0+0x32a/0x4e0 do_syscall_64+0x5d/0xfa0 entry_SYSCALL_64_after_hwframe+0x76/0x7e
This is because the kprobe on ftrace does not correctly handles the kprobe_ftrace_disabled flag set by ftrace_kill().
To prevent this error, check kprobe_ftrace_disabled in __disarm_kprobe_ftrace() and skip all ftrace related operations.
--- kernel/kprobes.c | 4 ++++ 1 file changed, 4 insertions(+)
kernel/kprobes.c +4 -0
@@ -1114,6 +1114,10 @@ static int __disarm_kprobe_ftrace(structint ret;lockdep_assert_held (&kprobe_mutex); +if (unlikely (kprobe_ftrace_disabled)) { +/* Now ftrace is disabled forever, disarm is already done. */ +return 0 ; + }if (*cnt ==1 ) { ret =unregister_ftrace_function (ops);
Greg Kroah-Hartman
maintainerPATCH 294/567 libceph: Fix potential out-of-bounds access in ceph_handle_auth_reply()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raphael Zimmer <[email protected]>
commit b282c43ed156ae15ea76748fc15cd5c39dc9ab72 upstream.
This patch fixes an out-of-bounds access in ceph_handle_auth_reply() that can be triggered by a message of type CEPH_MSG_AUTH_REPLY. In ceph_handle_auth_reply(), the value of the payload_len field of such a message is stored in a variable of type int. A value greater than INT_MAX leads to an integer overflow and is interpreted as a negative value. This leads to decrementing the pointer address by this value and subsequently accessing it because ceph_decode_need() only checks that the memory access does not exceed the end address of the allocation.
This patch fixes the issue by changing the data type of payload_len to u32. Additionally, the data type of result_msg_len is changed to u32, as it is also a variable holding a non-negative length.
Also, an additional layer of sanity checks is introduced, ensuring that directly after reading it from the message, payload_len and result_msg_len are not greater than the overall segment length.
BUG: KASAN: slab-out-of-bounds in ceph_handle_auth_reply+0x642/0x7a0 [libceph] Read of size 4 at addr ffff88811404df14 by task kworker/20:1/262 CPU: 20 UID: 0 PID: 262 Comm: kworker/20:1 Not tainted 6.19.2 #5 PREEMPT(voluntary) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Workqueue: ceph-msgr ceph_con_workfn [libceph] Call Trace: <TASK> dump_stack_lvl+0x76/0xa0 print_report+0xd1/0x620 ? __pfx__raw_spin_lock_irqsave+0x10/0x10 ? kasan_complete_mode_report_info+0x72/0x210 kasan_report+0xe7/0x130 ? ceph_handle_auth_reply+0x642/0x7a0 [libceph] ? ceph_handle_auth_reply+0x642/0x7a0 [libceph] __asan_report_load_n_noabort+0xf/0x20 ceph_handle_auth_reply+0x642/0x7a0 [libceph] mon_dispatch+0x973/0x23d0 [libceph] ? apparmor_socket_recvmsg+0x6b/0xa0 ? __pfx_mon_dispatch+0x10/0x10 [libceph] ? __kasan_check_write+0x14/0x30i ? mutex_unlock+0x7f/0xd0 ? __pfx_mutex_unlock+0x10/0x10 ? __pfx_do_recvmsg+0x10/0x10 [libceph] ceph_con_process_message+0x1f1/0x650 [libceph] process_message+0x1e/0x450 [libceph] ceph_con_v2_try_read+0x2e48/0x6c80 [libceph] ? __pfx_ceph_con_v2_try_read+0x10/0x10 [libceph] ? save_fpregs_to_fpstate+0xb0/0x230 ? raw_spin_rq_unlock+0x17/0xa0 ? finish_task_switch.isra.0+0x13b/0x760 ? __switch_to+0x385/0xda0 ? __kasan_check_write+0x14/0x30 ? mutex_lock+0x8d/0xe0 ? __pfx_mutex_lock+0x10/0x10 ceph_con_workfn+0x248/0x10c0 [libceph] process_one_work+0x629/0xf80 ? __kasan_check_write+0x14/0x30 worker_thread+0x87f/0x1570 ? __pfx__raw_spin_lock_irqsave+0x10/0x10 ? __pfx_try_to_wake_up+0x10/0x10 ? kasan_print_address_stack_frame+0x1f7/0x280 ? __pfx_worker_thread+0x10/0x10 kthread+0x396/0x830 ? __pfx__raw_spin_lock_irq+0x10/0x10 ? __pfx_kthread+0x10/0x10 ? __kasan_check_write+0x14/0x30 ? recalc_sigpending+0x180/0x210 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x3f7/0x610 ? __pfx_ret_from_fork+0x10/0x10 ? __switch_to+0x385/0xda0 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK>
[ idryomov: replace if statements with ceph_decode_need() for
payload_len and result_msg_len ]
--- net/ceph/auth.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/ceph/auth.c +4 -2
@@ -205,9 +205,9 @@ int ceph_handle_auth_reply(struct ceph_as32 result;u64 global_id;void *payload, *payload_end; -int payload_len; +u32 payload_len;char *result_msg; -int result_msg_len; +u32 result_msg_len;int ret = -EINVAL ;mutex_lock (&ac->mutex);
@@ -217,10 +217,12 @@ int ceph_handle_auth_reply(struct ceph_a result =ceph_decode_32 (&p); global_id =ceph_decode_64 (&p); payload_len =ceph_decode_32 (&p); +ceph_decode_need (&p, end, payload_len, bad); payload = p; p += payload_len;ceph_decode_need (&p, end,sizeof (u32), bad); result_msg_len =ceph_decode_32 (&p); +ceph_decode_need (&p, end, result_msg_len, bad); result_msg = p; p += result_msg_len;if (p != end)
Greg Kroah-Hartman
maintainerPATCH 295/567 libceph: reject preamble if control segment is empty
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Dryomov <[email protected]>
commit c4c22b846eceff05b1129b8844a80310e55a7f87 upstream.
While head_onwire_len() has a branch to handle ctrl_len == 0 case, prepare_read_control() always sets up a kvec for the CRC meaning that a non-empty control segment is effectively assumed. All frames that clients deal with meet that assumption, so let's make it official and treat the preamble with an empty control segment as malformed.
--- net/ceph/messenger_v2.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
net/ceph/messenger_v2.c +8 -9
@@ -392,7 +392,7 @@ static int head_onwire_len(int ctrl_len,int head_len;int rem_len; -BUG_ON (ctrl_len <0 || ctrl_len >CEPH_MSG_MAX_CONTROL_LEN ); +BUG_ON (ctrl_len <1 || ctrl_len >CEPH_MSG_MAX_CONTROL_LEN );if (secure) { head_len =CEPH_PREAMBLE_SECURE_LEN ;
@@ -401,9 +401,7 @@ static int head_onwire_len(int ctrl_len, head_len +=padded_len (rem_len) +CEPH_GCM_TAG_LEN ; } }else { - head_len =CEPH_PREAMBLE_PLAIN_LEN ; -if (ctrl_len) - head_len += ctrl_len +CEPH_CRC_LEN ; + head_len =CEPH_PREAMBLE_PLAIN_LEN + ctrl_len +CEPH_CRC_LEN ; }return head_len; }
@@ -528,11 +526,16 @@ static int decode_preamble(void *p, stru desc->fd_aligns[i] =ceph_decode_16 (&p); } -if (desc->fd_lens[0 ] <0 || +/* +* This would fire for FRAME_TAG_WAIT (it has one empty +* segment), but we should never get it as client. +*/ +if (desc->fd_lens[0 ] <1 || desc->fd_lens[0 ] >CEPH_MSG_MAX_CONTROL_LEN ) {pr_err ("bad control segment length %d\n" , desc->fd_lens[0 ]);return -EINVAL ; } +if (desc->fd_lens[1 ] <0 || desc->fd_lens[1 ] >CEPH_MSG_MAX_FRONT_LEN ) {pr_err ("bad front segment length %d\n" , desc->fd_lens[1 ]);
@@ -549,10 +552,6 @@ static int decode_preamble(void *p, strureturn -EINVAL ; } -/* -* This would fire for FRAME_TAG_WAIT (it has one empty -* segment), but we should never get it as client. -*/ if (!desc->fd_lens[desc->fd_seg_cnt -1 ]) {pr_err ("last segment empty, segment count %d\n" , desc->fd_seg_cnt);
Greg Kroah-Hartman
maintainerPATCH 296/567 libceph: prevent potential out-of-bounds reads in process_message_header()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Dryomov <[email protected]>
commit 69fb5d91bba44ecf7eb80530b85fa4fb028921d5 upstream.
If the message frame is (maliciously) corrupted in a way that the length of the control segment ends up being less than the size of the message header or a different frame is made to look like a message frame, out-of-bounds reads may ensue in process_message_header().
Perform an explicit bounds check before decoding the message header.
--- net/ceph/messenger_v2.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
net/ceph/messenger_v2.c +8 -1
@@ -2868,12 +2868,15 @@ static int process_message_header(struct void *p, void *end) { struct ceph_frame_desc *desc = &con->v2.in_desc; -struct ceph_msg_header2 *hdr2 = p; +struct ceph_msg_header2 *hdr2;struct ceph_msg_header hdr;int skip;int ret;u64 seq; +ceph_decode_need (&p, end,sizeof (*hdr2), bad); + hdr2 = p; +/* verify seq# */ seq =le64_to_cpu (hdr2->seq);if ((s64 )seq - (s64 )con->in_seq <1 ) {
@@ -2904,6 +2907,10 @@ static int process_message_header(structWARN_ON (!con->in_msg);WARN_ON (con->in_msg->con != con);return 1 ; + +bad: +pr_err ("failed to decode message header\n" ); +return -EINVAL ; }static int process_message (struct ceph_connection *con)
Greg Kroah-Hartman
maintainerPATCH 297/567 libceph: Use u32 for non-negative values in ceph_monmap_decode()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raphael Zimmer <[email protected]>
commit 770444611f047dbfd4517ec0bc1b179d40c2f346 upstream.
This patch fixes unnecessary implicit conversions that change signedness of blob_len and num_mon in ceph_monmap_decode().
Currently blob_len and num_mon are (signed) int variables. They are used to hold values that are always non-negative and get assigned in ceph_decode_32_safe(), which is meant to assign u32 values. Both variables are subsequently used as unsigned values, and the value of num_mon is further assigned to monmap->num_mon, which is of type u32. Therefore, both variables should be of type u32. This is especially relevant for num_mon. If the value read from the incoming message is very large, it is interpreted as a negative value, and the check for num_mon > CEPH_MAX_MON does not catch it. This leads to the attempt to allocate a very large chunk of memory for monmap, which will most likely fail. In this case, an unnecessary attempt to allocate memory is performed, and -ENOMEM is returned instead of -EINVAL.
--- net/ceph/mon_client.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/ceph/mon_client.c +3 -3
@@ -72,8 +72,8 @@ static struct ceph_monmap *ceph_monmap_dstruct ceph_monmap *monmap =NULL ;struct ceph_fsid fsid;u32 struct_len; -int blob_len; -int num_mon; +u32 blob_len; +u32 num_mon;u8 struct_v;u32 epoch;int ret;
@@ -112,7 +112,7 @@ static struct ceph_monmap *ceph_monmap_d }ceph_decode_32_safe (p, end, num_mon, e_inval); -dout ("%s fsid %pU epoch %u num_mon %d\n" , __func__, &fsid, epoch, +dout ("%s fsid %pU epoch %u num_mon %u\n" , __func__, &fsid, epoch, num_mon);if (num_mon >CEPH_MAX_MON ) goto e_inval;
Greg Kroah-Hartman
maintainerPATCH 298/567 libceph: admit message frames only in CEPH_CON_S_OPEN state
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Dryomov <[email protected]>
commit a5a373705081d7cc6363e16990e2361b0b362314 upstream.
Similar checks are performed for all control frames, but an early check for message frames was missing. process_message() is already set up to terminate the loop in case the state changes while con->ops->dispatch() handler is being executed.
--- net/ceph/messenger_v2.c | 5 +++++ 1 file changed, 5 insertions(+)
net/ceph/messenger_v2.c +5 -0
@@ -2940,6 +2940,11 @@ static int __handle_control(struct ceph_if (con->v2.in_desc.fd_tag !=FRAME_TAG_MESSAGE )return process_control (con, p, end); +if (con->state !=CEPH_CON_S_OPEN ) { + con->error_msg ="protocol error, unexpected message" ; +return -EINVAL ; + } + ret =process_message_header (con, p, end);if (ret <0 )return ret;
Greg Kroah-Hartman
maintainerPATCH 299/567 ceph: fix i_nlink underrun during async unlink
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Max Kellermann <[email protected]>
commit ce0123cbb4a40a2f1bbb815f292b26e96088639f upstream.
During async unlink, we drop the i_nlink counter before we receive the completion (that will eventually update the i_nlink) because "we assume that the unlink will succeed". That is not a bad idea, but it races against deletions by other clients (or against the completion of our own unlink) and can lead to an underrun which emits a WARNING like this one:
WARNING: CPU: 85 PID: 25093 at fs/inode.c:407 drop_nlink+0x50/0x68 Modules linked in: CPU: 85 UID: 3221252029 PID: 25093 Comm: php-cgi8.1 Not tainted 6.14.11-cm4all1-ampere #655 Hardware name: Supermicro ARS-110M-NR/R12SPD-A, BIOS 1.1b 10/17/2023 pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : drop_nlink+0x50/0x68 lr : ceph_unlink+0x6c4/0x720 sp : ffff80012173bc90 x29: ffff80012173bc90 x28: ffff086d0a45aaf8 x27: ffff0871d0eb5680 x26: ffff087f2a64a718 x25: 0000020000000180 x24: 0000000061c88647 x23: 0000000000000002 x22: ffff07ff9236d800 x21: 0000000000001203 x20: ffff07ff9237b000 x19: ffff088b8296afc0 x18: 00000000f3c93365 x17: 0000000000070000 x16: ffff08faffcbdfe8 x15: ffff08faffcbdfec x14: 0000000000000000 x13: 45445f65645f3037 x12: 34385f6369706f74 x11: 0000a2653104bb20 x10: ffffd85f26d73290 x9 : ffffd85f25664f94 x8 : 00000000000000c0 x7 : 0000000000000000 x6 : 0000000000000002 x5 : 0000000000000081 x4 : 0000000000000481 x3 : 0000000000000000 x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff08727d3f91e8 Call trace: drop_nlink+0x50/0x68 (P) vfs_unlink+0xb0/0x2e8 do_unlinkat+0x204/0x288 __arm64_sys_unlinkat+0x3c/0x80 invoke_syscall.constprop.0+0x54/0xe8 do_el0_svc+0xa4/0xc8 el0_svc+0x18/0x58 el0t_64_sync_handler+0x104/0x130 el0t_64_sync+0x154/0x158
In ceph_unlink(), a call to ceph_mdsc_submit_request() submits the CEPH_MDS_OP_UNLINK to the MDS, but does not wait for completion.
Meanwhile, between this call and the following drop_nlink() call, a worker thread may process a CEPH_CAP_OP_IMPORT, CEPH_CAP_OP_GRANT or just a CEPH_MSG_CLIENT_REPLY (the latter of which could be our own completion). These will lead to a set_nlink() call, updating the i_nlink counter to the value received from the MDS. If that new i_nlink value happens to be zero, it is illegal to decrement it further. But that is exactly what ceph_unlink() will do then.
The WARNING can be reproduced this way:
1. Force async unlink; only the async code path is affected. Having no real clue about Ceph internals, I was unable to find out why the MDS wouldn't give me the "Fxr" capabilities, so I patched get_caps_for_async_unlink() to always succeed.
(Note that the WARNING dump above was found on an unpatched kernel, without this kludge - this is not a theoretical bug.)
2. Add a sleep call after ceph_mdsc_submit_request() so the unlink completion gets handled by a worker thread before drop_nlink() is called. This guarantees that the i_nlink is already zero before drop_nlink() runs.
The solution is to skip the counter decrement when it is already zero, but doing so without a lock is still racy (TOCTOU). Since ceph_fill_inode() and handle_cap_grant() both hold the ceph_inode_info.i_ceph_lock spinlock while set_nlink() runs, this seems like the proper lock to protect the i_nlink updates.
I found prior art in NFS and SMB (using inode.i_lock) and AFS (using afs_vnode.cb_lock). All three have the zero check as well.
--- fs/ceph/dir.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
fs/ceph/dir.c +14 -1
@@ -1292,6 +1292,7 @@ static int ceph_unlink(struct inode *dirstruct ceph_fs_client *fsc =ceph_sb_to_fs_client (dir->i_sb);struct ceph_mds_client *mdsc = fsc->mdsc;struct inode *inode =d_inode (dentry); +struct ceph_inode_info *ci =ceph_inode (inode);struct ceph_mds_request *req;bool try_async =ceph_test_mount_opt (fsc,ASYNC_DIROPS );int err = -EROFS ;
@@ -1349,7 +1350,19 @@ retry:* We have enough caps, so we assume that the unlink * will succeed. Fix up the target inode and dcache. */ -drop_nlink (inode); + +/* +* Protect the i_nlink update with i_ceph_lock +* to precent racing against ceph_fill_inode() +* handling our completion on a worker thread +* and don't decrement if i_nlink has already +* been updated to zero by this completion. +*/ +spin_lock (&ci->i_ceph_lock); +if (inode->i_nlink >0 ) +drop_nlink (inode); +spin_unlock (&ci->i_ceph_lock); +d_delete (dentry); }else {spin_lock (&fsc->async_unlink_conflict_lock);
Greg Kroah-Hartman
maintainerPATCH 300/567 ceph: fix memory leaks in ceph_mdsc_build_path()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Max Kellermann <[email protected]>
commit 040d159a45ded7f33201421a81df0aa2a86e5a0b upstream.
Add __putname() calls to error code paths that did not free the "path" pointer obtained by __getname(). If ownership of this pointer is not passed to the caller via path_info.path, the function must free it before returning.
--- fs/ceph/mds_client.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ceph/mds_client.c +3 -0
@@ -2672,6 +2672,7 @@ retry:if (ret <0 ) {dput (parent);dput (cur); +__putname (path);return ERR_PTR (ret); }
@@ -2681,6 +2682,7 @@ retry:if (len <0 ) {dput (parent);dput (cur); +__putname (path);return ERR_PTR (len); } }
@@ -2717,6 +2719,7 @@ retry:* cannot ever succeed. Creating paths that long is * possible with Ceph, but Linux cannot use them. */ +__putname (path);return ERR_PTR (-ENAMETOOLONG ); }
Greg Kroah-Hartman
maintainerPATCH 301/567 time/jiffies: Mark jiffies_64_to_clock_t() notrace
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
[ Upstream commit 755a648e78f12574482d4698d877375793867fa1 ]
The trace_clock_jiffies() function that handles the "uptime" clock for tracing calls jiffies_64_to_clock_t(). This causes the function tracer to constantly recurse when the tracing clock is set to "uptime". Mark it notrace to prevent unnecessary recursion when using the "uptime" clock.
--- kernel/time/time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/time.c +1 -1
@@ -702,7 +702,7 @@ EXPORT_SYMBOL(clock_t_to_jiffies);* * Return: jiffies_64 value converted to 64-bit "clock_t" (CLOCKS_PER_SEC) */ -u64 jiffies_64_to_clock_t (u64 x) +notrace u64 jiffies_64_to_clock_t(u64 x) {#if (TICK_NSEC % (NSEC_PER_SEC /USER_HZ )) ==0 # if HZ <USER_HZ
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 302/567 i3c: dw-i3c-master: Set SIR_REJECT in DAT on device attach and reattach
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Ng Ho Yin <[email protected]>
[ Upstream commit f311a05784634febd299f03476b80f3f18489767 ]
The DesignWare I3C master controller ACKs IBIs as soon as a valid Device Address Table (DAT) entry is present. This can create a race between device attachment (after DAA) and the point where the client driver enables IBIs via i3c_device_enable_ibi().
Set DEV_ADDR_TABLE_SIR_REJECT in the DAT entry during attach_i3c_dev() and reattach_i3c_dev() so that IBIs are rejected by default. The bit is managed thereafter by the existing dw_i3c_master_set_sir_enabled() function, which clears it in enable_ibi() after ENEC is issued, and restores it in disable_ibi() after DISEC.
--- drivers/i3c/master/dw-i3c-master.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i3c/master/dw-i3c-master.c +2 -2
@@ -941,7 +941,7 @@ static int dw_i3c_master_reattach_i3c_dev(struct i3c_dev_desc *dev, master->free_pos &= ~BIT (pos); } -writel (DEV_ADDR_TABLE_DYNAMIC_ADDR (dev->info.dyn_addr), +writel (DEV_ADDR_TABLE_DYNAMIC_ADDR (dev->info.dyn_addr) |DEV_ADDR_TABLE_SIR_REJECT , master->regs +DEV_ADDR_TABLE_LOC (master->datstartaddr, data->index));
@@ -970,7 +970,7 @@ static int dw_i3c_master_attach_i3c_dev(struct i3c_dev_desc *dev) master->free_pos &= ~BIT (pos);i3c_dev_set_master_data (dev, data); -writel (DEV_ADDR_TABLE_DYNAMIC_ADDR (master->devs[pos].addr), +writel (DEV_ADDR_TABLE_DYNAMIC_ADDR (master->devs[pos].addr) |DEV_ADDR_TABLE_SIR_REJECT , master->regs +DEV_ADDR_TABLE_LOC (master->datstartaddr, data->index));
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 303/567 scsi: ufs: core: Fix SError in ufshcd_rtc_work() during UFS suspend
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Shuaiwei <[email protected]>
[ Upstream commit b0bd84c39289ef6a6c3827dd52c875659291970a ]
In __ufshcd_wl_suspend(), cancel_delayed_work_sync() is called to cancel the UFS RTC work, but it is placed after ufshcd_vops_suspend(hba, pm_op, POST_CHANGE). This creates a race condition where ufshcd_rtc_work() can still be running while ufshcd_vops_suspend() is executing. When UFSHCD_CAP_CLK_GATING is not supported, the condition !hba->clk_gating.active_reqs is always true, causing ufshcd_update_rtc() to be executed. Since ufshcd_vops_suspend() typically performs clock gating operations, executing ufshcd_update_rtc() at that moment triggers an SError. The kernel panic trace is as follows:
Kernel panic - not syncing: Asynchronous SError Interrupt Call trace: dump_backtrace+0xec/0x128 show_stack+0x18/0x28 dump_stack_lvl+0x40/0xa0 dump_stack+0x18/0x24 panic+0x148/0x374 nmi_panic+0x3c/0x8c arm64_serror_panic+0x64/0x8c do_serror+0xc4/0xc8 el1h_64_error_handler+0x34/0x4c el1h_64_error+0x68/0x6c el1_interrupt+0x20/0x58 el1h_64_irq_handler+0x18/0x24 el1h_64_irq+0x68/0x6c ktime_get+0xc4/0x12c ufshcd_mcq_sq_stop+0x4c/0xec ufshcd_mcq_sq_cleanup+0x64/0x1dc ufshcd_clear_cmd+0x38/0x134 ufshcd_issue_dev_cmd+0x298/0x4d0 ufshcd_exec_dev_cmd+0x1a4/0x1c4 ufshcd_query_attr+0xbc/0x19c ufshcd_rtc_work+0x10c/0x1c8 process_scheduled_works+0x1c4/0x45c worker_thread+0x32c/0x3e8 kthread+0x120/0x1d8 ret_from_fork+0x10/0x20
Fix this by moving cancel_delayed_work_sync() before the call to ufshcd_vops_suspend(hba, pm_op, PRE_CHANGE), ensuring the UFS RTC work is fully completed or cancelled at that point.
--- drivers/ufs/core/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ufs/core/ufshcd.c +1 -1
@@ -9882,6 +9882,7 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) }flush_work (&hba->eeh_work); +cancel_delayed_work_sync (&hba->ufs_rtc_update_work); ret =ufshcd_vops_suspend (hba, pm_op,PRE_CHANGE );if (ret)
@@ -9936,7 +9937,6 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)if (ret) goto set_link_active; -cancel_delayed_work_sync (&hba->ufs_rtc_update_work); goto out; set_link_active:
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 304/567 scsi: hisi_sas: Add time interval between two H2D FIS following soft reset spec
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xingui Yang <[email protected]>
[ Upstream commit 3c62791322e42d1afd65acfdb5b3a371bde21ede ]
Spec says at least 5us between two H2D FIS when do soft reset, but be generous and sleep for about 1ms.
Stable-dep-of: 8ddc0c269165 ("scsi: hisi_sas: Fix NULL pointer exception during user_scan()")
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/hisi_sas/hisi_sas_main.c +1 -0
@@ -1340,6 +1340,7 @@ static int hisi_sas_softreset_ata_disk(struct domain_device *device) }if (rc ==TMF_RESP_FUNC_COMPLETE ) { +usleep_range (900 ,1000 );ata_for_each_link (link, ap,EDGE ) {int pmp =sata_srst_pmp (link);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 305/567 scsi: hisi_sas: Use macro instead of magic number
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yihang Li <[email protected]>
[ Upstream commit 4ca7fe99fc8485fcd04b367f37dc7a48f1355419 ]
The hisi_sas driver has a large number of magic numbers which makes for unfriendly code reading. Use macro definitions instead.
Stable-dep-of: 8ddc0c269165 ("scsi: hisi_sas: Fix NULL pointer exception during user_scan()")
--- drivers/scsi/hisi_sas/hisi_sas.h | 43 +++-- drivers/scsi/hisi_sas/hisi_sas_main.c | 41 +++-- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 244 ++++++++++++++++--------- 3 files changed, 213 insertions(+), 115 deletions(-)
drivers/scsi/hisi_sas/hisi_sas.h +32 -11
@@ -47,6 +47,13 @@#define HISI_SAS_IOST_ITCT_CACHE_DW_SZ 10#define HISI_SAS_FIFO_DATA_DW_SIZE 32 +#define HISI_SAS_REG_MEM_SIZE 4 +#define HISI_SAS_MAX_CDB_LEN 16 +#define HISI_SAS_BLK_QUEUE_DEPTH 64 + +#define BYTE_TO_DW 4 +#define BYTE_TO_DDW 8 +#define HISI_SAS_STATUS_BUF_SZ (sizeof(struct hisi_sas_status_buffer))#define HISI_SAS_COMMAND_TABLE_SZ (sizeof(union hisi_sas_command_table))
@@ -93,6 +100,8 @@#define HISI_SAS_WAIT_PHYUP_TIMEOUT (30 * HZ)#define HISI_SAS_CLEAR_ITCT_TIMEOUT (20 * HZ) +#define HISI_SAS_DELAY_FOR_PHY_DISABLE 100 +#define NAME_BUF_SIZE 256struct hisi_hba ;
@@ -168,6 +177,8 @@ struct hisi_sas_debugfs_fifo {u32 rd_data[HISI_SAS_FIFO_DATA_DW_SIZE ]; }; +#define FRAME_RCVD_BUF 32 +#define SAS_PHY_RESV_SIZE 2struct hisi_sas_phy {struct work_struct works[HISI_PHYES_NUM ];struct hisi_hba *hisi_hba;
@@ -179,10 +190,10 @@ struct hisi_sas_phy {spinlock_t lock;u64 port_id;/* from hw */ u64 frame_rcvd_size; -u8 frame_rcvd[32 ]; +u8 frame_rcvd[FRAME_RCVD_BUF ];u8 phy_attached;u8 in_reset; -u8 reserved[2 ]; +u8 reserved[SAS_PHY_RESV_SIZE ];u32 phy_type;u32 code_violation_err_count;enum sas_linkrate minimum_linkrate;
@@ -349,6 +360,7 @@ struct hisi_sas_hw { };#define HISI_SAS_MAX_DEBUGFS_DUMP (50) +#define HISI_SAS_DEFAULT_DEBUGFS_DUMP 1struct hisi_sas_debugfs_cq {struct hisi_sas_cq *cq;
@@ -528,12 +540,13 @@ struct hisi_sas_cmd_hdr {__le64 dif_prd_table_addr; }; +#define ITCT_RESV_DDW 12struct hisi_sas_itct {__le64 qw0;__le64 sas_addr;__le64 qw2;__le64 qw3; -__le64 qw4_15[12 ]; +__le64 qw4_15[ITCT_RESV_DDW ]; };struct hisi_sas_iost {
@@ -543,22 +556,26 @@ struct hisi_sas_iost {__le64 qw3; }; +#define ERROR_RECORD_BUF_DW 4struct hisi_sas_err_record { -u32 data[4 ]; +u32 data[ERROR_RECORD_BUF_DW ]; }; +#define FIS_RESV_DW 3struct hisi_sas_initial_fis {struct hisi_sas_err_record err_record;struct dev_to_host_fis fis; -u32 rsvd[3 ]; +u32 rsvd[FIS_RESV_DW ]; }; +#define BREAKPOINT_DATA_SIZE 128struct hisi_sas_breakpoint { -u8 data[128 ]; +u8 data[BREAKPOINT_DATA_SIZE ]; }; +#define BREAKPOINT_TAG_NUM 32struct hisi_sas_sata_breakpoint { -struct hisi_sas_breakpoint tag[32 ]; +struct hisi_sas_breakpoint tag[BREAKPOINT_TAG_NUM ]; };struct hisi_sas_sge {
@@ -569,13 +586,15 @@ struct hisi_sas_sge {__le32 data_off; }; +#define SMP_CMD_TABLE_SIZE 44struct hisi_sas_command_table_smp { -u8 bytes[44 ]; +u8 bytes[SMP_CMD_TABLE_SIZE ]; }; +#define DUMMY_BUF_SIZE 12struct hisi_sas_command_table_stp {struct host_to_dev_fis command_fis; -u8 dummy[12 ]; +u8 dummy[DUMMY_BUF_SIZE ];u8 atapi_cdb[ATAPI_CDB_LEN ]; };
@@ -589,12 +608,13 @@ struct hisi_sas_sge_dif_page {struct hisi_sas_sge sge[HISI_SAS_SGE_DIF_PAGE_CNT ]; }__aligned(16) ; +#define PROT_BUF_SIZE 7struct hisi_sas_command_table_ssp {struct ssp_frame_hdr hdr;union {struct {struct ssp_command_iu task; -u32 prot[7 ]; +u32 prot[PROT_BUF_SIZE ]; };struct ssp_tmf_iu ssp_task;struct xfer_rdy_iu xfer_rdy;
@@ -608,9 +628,10 @@ union hisi_sas_command_table {struct hisi_sas_command_table_stp stp; }__aligned(16) ; +#define IU_BUF_SIZE 1024struct hisi_sas_status_buffer {struct hisi_sas_err_record err; -u8 iu[1024 ]; +u8 iu[IU_BUF_SIZE ]; }__aligned(16) ;struct hisi_sas_slot_buf_table {
drivers/scsi/hisi_sas/hisi_sas_main.c +28 -13
123 lines not on this page · raw message
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +153 -91
668 lines not on this page · raw message
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 306/567 scsi: hisi_sas: Fix NULL pointer exception during user_scan()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xingui Yang <[email protected]>
[ Upstream commit 8ddc0c26916574395447ebf4cff684314f6873a9 ]
user_scan() invokes updated sas_user_scan() for channel 0, and if successful, iteratively scans remaining channels (1 to shost->max_channel) via scsi_scan_host_selected() in commit 37c4e72b0651 ("scsi: Fix sas_user_scan() to handle wildcard and multi-channel scans"). However, hisi_sas supports only one channel, and the current value of max_channel is
1. sas_user_scan() for channel 1 will trigger the following NULL pointer exception:
[ 441.554662] Unable to handle kernel NULL pointer dereference at virtual address 00000000000008b0 [ 441.554699] Mem abort info: [ 441.554710] ESR = 0x0000000096000004 [ 441.554718] EC = 0x25: DABT (current EL), IL = 32 bits [ 441.554723] SET = 0, FnV = 0 [ 441.554726] EA = 0, S1PTW = 0 [ 441.554730] FSC = 0x04: level 0 translation fault [ 441.554735] Data abort info: [ 441.554737] ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000 [ 441.554742] CM = 0, WnR = 0, TnD = 0, TagAccess = 0 [ 441.554747] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 [ 441.554752] user pgtable: 4k pages, 48-bit VAs, pgdp=00000828377a6000 [ 441.554757] [00000000000008b0] pgd=0000000000000000, p4d=0000000000000000 [ 441.554769] Internal error: Oops: 0000000096000004 [#1] SMP [ 441.629589] Modules linked in: arm_spe_pmu arm_smmuv3_pmu tpm_tis_spi hisi_uncore_sllc_pmu hisi_uncore_pa_pmu hisi_uncore_l3c_pmu hisi_uncore_hha_pmu hisi_uncore_ddrc_pmu hisi_uncore_cpa_pmu hns3_pmu hisi_ptt hisi_pcie_pmu tpm_tis_core spidev spi_hisi_sfc_v3xx hisi_uncore_pmu spi_dw_mmio fuse hclge hclge_common hisi_sec2 hisi_hpre hisi_zip hisi_qm hns3 hisi_sas_v3_hw sm3_ce sbsa_gwdt hnae3 hisi_sas_main uacce hisi_dma i2c_hisi dm_mirror dm_region_hash dm_log dm_mod [ 441.670819] CPU: 46 UID: 0 PID: 6994 Comm: bash Kdump: loaded Not tainted 7.0.0-rc2+ #84 PREEMPT [ 441.691327] pstate: 81400009 (Nzcv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--) [ 441.698277] pc : sas_find_dev_by_rphy+0x44/0x118 [ 441.702896] lr : sas_find_dev_by_rphy+0x3c/0x118 [ 441.707502] sp : ffff80009abbba40 [ 441.710805] x29: ffff80009abbba40 x28: ffff082819a40008 x27: ffff082810c37c08 [ 441.717930] x26: ffff082810c37c28 x25: ffff082819a40290 x24: ffff082810c37c00 [ 441.725054] x23: 0000000000000000 x22: 0000000000000001 x21: ffff082819a40000 [ 441.732179] x20: ffff082819a40290 x19: 0000000000000000 x18: 0000000000000020 [ 441.739304] x17: 0000000000000000 x16: ffffb5dad6bda690 x15: 00000000ffffffff [ 441.746428] x14: ffff082814c3b26c x13: 00000000ffffffff x12: ffff082814c3b26a [ 441.753553] x11: 00000000000000c0 x10: 000000000000003a x9 : ffffb5dad5ea94f4 [ 441.760678] x8 : 000000000000003a x7 : ffff80009abbbab0 x6 : 0000000000000030 [ 441.767802] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000 [ 441.774926] x2 : ffff08280f35a300 x1 : ffffb5dad7127180 x0 : 0000000000000000 [ 441.782053] Call trace: [ 441.784488] sas_find_dev_by_rphy+0x44/0x118 (P) [ 441.789095] sas_target_alloc+0x24/0xb0 [ 441.792920] scsi_alloc_target+0x290/0x330 [ 441.797010] __scsi_scan_target+0x88/0x258 [ 441.801096] scsi_scan_channel+0x74/0xb8 [ 441.805008] scsi_scan_host_selected+0x170/0x188 [ 441.809615] sas_user_scan+0xfc/0x148 [ 441.813267] store_scan+0x10c/0x180 [ 441.816743] dev_attr_store+0x20/0x40 [ 441.820398] sysfs_kf_write+0x84/0xa8 [ 441.824054] kernfs_fop_write_iter+0x130/0x1c8 [ 441.828487] vfs_write+0x2c0/0x370 [ 441.831880] ksys_write+0x74/0x118 [ 441.835271] __arm64_sys_write+0x24/0x38 [ 441.839182] invoke_syscall+0x50/0x120 [ 441.842919] el0_svc_common.constprop.0+0xc8/0xf0 [ 441.847611] do_el0_svc+0x24/0x38 [ 441.850913] el0_svc+0x38/0x158 [ 441.854043] el0t_64_sync_handler+0xa0/0xe8 [ 441.858214] el0t_64_sync+0x1ac/0x1b0 [ 441.861865] Code: aa1303e0 97ff70a8 34ffff80 d10a4273 (f9445a75) [ 441.867946] ---[ end trace 0000000000000000 ]---
Therefore, set max_channel to 0.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +1 -1
@@ -2537,7 +2537,7 @@ int hisi_sas_probe(struct platform_device *pdev, shost->transportt = hisi_sas_stt; shost->max_id =HISI_SAS_MAX_DEVICES ; shost->max_lun = ~0 ; - shost->max_channel =1 ; + shost->max_channel =0 ; shost->max_cmd_len =HISI_SAS_MAX_CDB_LEN ;if (hisi_hba->hw->slot_index_alloc) { shost->can_queue =HISI_SAS_MAX_COMMANDS ;
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +1 -1
@@ -5087,7 +5087,7 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id) shost->transportt = hisi_sas_stt; shost->max_id =HISI_SAS_MAX_DEVICES ; shost->max_lun = ~0 ; - shost->max_channel =1 ; + shost->max_channel =0 ; shost->max_cmd_len =HISI_SAS_MAX_CDB_LEN ; shost->can_queue =HISI_SAS_UNRESERVED_IPTT ; shost->cmd_per_lun =HISI_SAS_UNRESERVED_IPTT ;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 307/567 Revert "tcpm: allow looking for role_sw device in the main node"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Yang <[email protected]>
commit 6b275bfaa16be3fb1689fa6794e445ecd127a1b4 upstream.
This reverts commit 1366cd228b0c67b60a2c0c26ef37fe9f7cfedb7f.
The fwnode_usb_role_switch_get() returns NULL only if no connection is found, returns ERR_PTR(-EPROBE_DEFER) if connection is found but deferred probe is needed, or a valid pointer of usb_role_switch.
When switching from a NULL check to IS_ERR_OR_NULL(), usb_role_switch_get() returns NULL and overwrites the ERR_PTR(-EPROBE_DEFER) returned by fwnode_usb_role_switch_get(). This causes the deferred probe indication to be lost, preventing the USB role switch from ever being retrieved.
--- drivers/usb/typec/tcpm/tcpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/tcpm/tcpm.c +1 -1
@@ -6637,7 +6637,7 @@ struct tcpm_port *tcpm_register_port(str port->port_type = port->typec_caps.type; port->role_sw =fwnode_usb_role_switch_get (tcpc->fwnode); -if (IS_ERR_OR_NULL (port->role_sw)) +if (!port->role_sw) port->role_sw =usb_role_switch_get (port->dev);if (IS_ERR (port->role_sw)) { err =PTR_ERR (port->role_sw);
Greg Kroah-Hartman
maintainerPATCH 308/567 drm/bridge: samsung-dsim: Fix memory leak in error path
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Osama Abdelkader <[email protected]>
commit 803ec1faf7c1823e6e3b1f2aaa81be18528c9436 upstream.
In samsung_dsim_host_attach(), drm_bridge_add() is called to add the bridge. However, if samsung_dsim_register_te_irq() or pdata->host_ops->attach() fails afterwards, the function returns without removing the bridge, causing a memory leak.
Fix this by adding proper error handling with goto labels to ensure drm_bridge_remove() is called in all error paths. Also ensure that samsung_dsim_unregister_te_irq() is called if the attach operation fails after the TE IRQ has been registered.
samsung_dsim_unregister_te_irq() function is moved without changes to be before samsung_dsim_host_attach() to avoid forward declaration.
--- drivers/gpu/drm/bridge/samsung-dsim.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)
drivers/gpu/drm/bridge/samsung-dsim.c +16 -9
@@ -1642,6 +1642,14 @@ static int samsung_dsim_register_te_irq(return 0 ; } +static void samsung_dsim_unregister_te_irq (struct samsung_dsim *dsi) +{ +if (dsi->te_gpio) { +free_irq (gpiod_to_irq (dsi->te_gpio), dsi); +gpiod_put (dsi->te_gpio); + } +} +static int samsung_dsim_host_attach (struct mipi_dsi_host *host,struct mipi_dsi_device *device) {
@@ -1713,13 +1721,13 @@ of_find_panel_or_bridge:if (!(device->mode_flags &MIPI_DSI_MODE_VIDEO )) { ret =samsung_dsim_register_te_irq (dsi, &device->dev);if (ret) -return ret; + goto err_remove_bridge; }if (pdata->host_ops && pdata->host_ops->attach) { ret = pdata->host_ops->attach (dsi, device);if (ret) -return ret; + goto err_unregister_te_irq; } dsi->lanes = device->lanes;
@@ -1727,14 +1735,13 @@ of_find_panel_or_bridge: dsi->mode_flags = device->mode_flags;return 0 ; -} -static void samsung_dsim_unregister_te_irq (struct samsung_dsim *dsi) -{ -if (dsi->te_gpio) { -free_irq (gpiod_to_irq (dsi->te_gpio), dsi); -gpiod_put (dsi->te_gpio); - } +err_unregister_te_irq: +if (!(device->mode_flags &MIPI_DSI_MODE_VIDEO )) +samsung_dsim_unregister_te_irq (dsi); +err_remove_bridge: +drm_bridge_remove (&dsi->bridge); +return ret; } static int samsung_dsim_host_detach(struct mipi_dsi_host *host,
Greg Kroah-Hartman
maintainerPATCH 309/567 drm/bridge: ti-sn65dsi86: Enable HPD polling if IRQ is not used
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Franz Schnyder <[email protected]>
commit 0b87d51690dd5131cbe9fbd23746b037aab89815 upstream.
Fallback to polling to detect hotplug events on systems without interrupts.
On systems where the interrupt line of the bridge is not connected, the bridge cannot notify hotplug events. Only add the DRM_BRIDGE_OP_HPD flag if an interrupt has been registered otherwise remain in polling mode.
--- drivers/gpu/drm/bridge/ti-sn65dsi86.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/ti-sn65dsi86.c +4 -2
@@ -1326,6 +1326,7 @@ static int ti_sn_bridge_probe(struct aux {struct ti_sn65dsi86 *pdata =dev_get_drvdata (adev->dev.parent);struct device_node *np = pdata->dev->of_node; +const struct i2c_client *client =to_i2c_client (pdata->dev);int ret; pdata->next_bridge =devm_drm_of_get_bridge (&adev->dev, np,1 ,0 );
@@ -1345,8 +1346,9 @@ static int ti_sn_bridge_probe(struct aux ? DRM_MODE_CONNECTOR_DisplayPort : DRM_MODE_CONNECTOR_eDP;if (pdata->bridge.type == DRM_MODE_CONNECTOR_DisplayPort) { - pdata->bridge.ops =DRM_BRIDGE_OP_EDID |DRM_BRIDGE_OP_DETECT | -DRM_BRIDGE_OP_HPD ; + pdata->bridge.ops =DRM_BRIDGE_OP_EDID |DRM_BRIDGE_OP_DETECT ; +if (client->irq) + pdata->bridge.ops |=DRM_BRIDGE_OP_HPD ;/* * If comms were already enabled they would have been enabled * with the wrong value of HPD_DISABLE. Update it now. Comms
Greg Kroah-Hartman
maintainerPATCH 310/567 device property: Allow secondary lookup in fwnode_get_next_child_node()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
commit 2692c614f8f05929d692b3dbfd3faef1f00fbaf0 upstream.
When device_get_child_node_count() got split to the fwnode and device respective APIs, the fwnode didn't inherit the ability to traverse over the secondary fwnode. Hence any user, that switches from device to fwnode API misses this feature. In particular, this was revealed by the commit 1490cbb9dbfd ("device property: Split fwnode_get_child_node_count()") that effectively broke the GPIO enumeration on Intel Galileo boards. Fix this by moving the secondary lookup from device to fwnode API.
Note, in general no device_*() API should go into the depth of the fwnode implementation.
--- drivers/base/property.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
drivers/base/property.c +13 -14
@@ -750,7 +750,18 @@ struct fwnode_handle * fwnode_get_next_child_node(const struct fwnode_handle *fwnode, struct fwnode_handle *child) { - return fwnode_call_ptr_op(fwnode, get_next_child_node, child); + struct fwnode_handle *next; + +if (IS_ERR_OR_NULL (fwnode)) +return NULL ; + +/* Try to find a child in primary fwnode */ + next =fwnode_call_ptr_op (fwnode, get_next_child_node, child); +if (next) +return next; + +/* When no more children in primary, continue with secondary */ +return fwnode_call_ptr_op (fwnode->secondary, get_next_child_node, child); }EXPORT_SYMBOL_GPL (fwnode_get_next_child_node);
@@ -794,19 +805,7 @@ EXPORT_SYMBOL_GPL(fwnode_get_next_availastruct fwnode_handle *device_get_next_child_node (const struct device *dev,struct fwnode_handle *child) { -const struct fwnode_handle *fwnode =dev_fwnode (dev); -struct fwnode_handle *next; - -if (IS_ERR_OR_NULL (fwnode)) -return NULL ; - -/* Try to find a child in primary fwnode */ - next =fwnode_get_next_child_node (fwnode, child); -if (next) -return next; - -/* When no more children in primary, continue with secondary */ -return fwnode_get_next_child_node (fwnode->secondary, child); +return fwnode_get_next_child_node (dev_fwnode (dev), child); }EXPORT_SYMBOL_GPL (device_get_next_child_node);
Greg Kroah-Hartman
maintainerPATCH 311/567 irqchip/gic-v3-its: Limit number of per-device MSIs to the range the ITS supports
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
commit ce9e40a9a5e5cff0b1b0d2fa582b3d71a8ce68e8 upstream.
The ITS driver blindly assumes that EventIDs are in abundant supply, to the point where it never checks how many the hardware actually supports.
It turns out that some pretty esoteric integrations make it so that only a few bits are available, all the way down to a single bit.
Enforce the advertised limitation at the point of allocating the device structure, and hope that the endpoint driver can deal with such limitation.
--- drivers/irqchip/irq-gic-v3-its.c | 4 ++++ include/linux/irqchip/arm-gic-v3.h | 1 + 2 files changed, 5 insertions(+)
drivers/irqchip/irq-gic-v3-its.c +4 -0
@@ -3402,6 +3402,7 @@ static struct its_device *its_create_devint lpi_base;int nr_lpis;int nr_ites; +int id_bits;int sz;if (!its_alloc_device_table (its, dev_id))
@@ -3414,7 +3415,10 @@ static struct its_device *its_create_dev/* * Even if the device wants a single LPI, the ITT must be * sized as a power of two (and you need at least one bit...). +* Also honor the ITS's own EID limit. */ + id_bits =FIELD_GET (GITS_TYPER_IDBITS , its->typer) +1 ; + nvecs = min_t(unsigned int, nvecs, BIT(id_bits)); nr_ites =max (2 , nvecs); sz = nr_ites * (FIELD_GET (GITS_TYPER_ITT_ENTRY_SIZE , its->typer) +1 ); sz =max (sz,ITS_ITT_ALIGN ) +ITS_ITT_ALIGN -1 ;
include/linux/irqchip/arm-gic-v3.h +1 -0
@@ -394,6 +394,7 @@#define GITS_TYPER_VLPIS (1UL << 1)#define GITS_TYPER_ITT_ENTRY_SIZE_SHIFT 4#define GITS_TYPER_ITT_ENTRY_SIZE GENMASK_ULL(7, 4) +#define GITS_TYPER_IDBITS GENMASK_ULL(12, 8)#define GITS_TYPER_IDBITS_SHIFT 8#define GITS_TYPER_DEVBITS_SHIFT 13#define GITS_TYPER_DEVBITS GENMASK_ULL(17, 13)
Greg Kroah-Hartman
maintainerPATCH 312/567 ice: reintroduce retry mechanism for indirect AQ
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Staniszewski <[email protected]>
commit 326256c0a72d4877cec1d4df85357da106233128 upstream.
Add retry mechanism for indirect Admin Queue (AQ) commands. To do so we need to keep the command buffer.
This technically reverts commit 43a630e37e25
("ice: remove unused buffer copy code in ice_sq_send_cmd_retry()"), but combines it with a fix in the logic by using a kmemdup() call, making it more robust and less likely to break in the future due to programmer error.
--- drivers/net/ethernet/intel/ice/ice_common.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/ice/ice_common.c +9 -3
@@ -1636,6 +1636,7 @@ ice_sq_send_cmd_retry(struct ice_hw *hw, {struct ice_aq_desc desc_cpy;bool is_cmd_for_retry; +u8 *buf_cpy =NULL ;u8 idx =0 ;u16 opcode;int status;
@@ -1645,8 +1646,11 @@ ice_sq_send_cmd_retry(struct ice_hw *hw,memset (&desc_cpy,0 ,sizeof (desc_cpy));if (is_cmd_for_retry) { -/* All retryable cmds are direct, without buf. */ -WARN_ON (buf); +if (buf) { + buf_cpy =kmemdup (buf, buf_size,GFP_KERNEL ); +if (!buf_cpy) +return -ENOMEM ; + }memcpy (&desc_cpy, desc,sizeof (desc_cpy)); }
@@ -1658,12 +1662,14 @@ ice_sq_send_cmd_retry(struct ice_hw *hw, hw->adminq.sq_last_status != ICE_AQ_RC_EBUSY) break; +if (buf_cpy) +memcpy (buf, buf_cpy, buf_size);memcpy (desc, &desc_cpy,sizeof (desc_cpy)); -msleep (ICE_SQ_SEND_DELAY_TIME_MS ); }while (++idx <ICE_SQ_SEND_MAX_EXECUTE ); +kfree (buf_cpy);return status; }
Greg Kroah-Hartman
maintainerPATCH 313/567 ixgbevf: fix link setup issue
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jedrzej Jagielski <[email protected]>
commit feae40a6a178bb525a15f19288016e5778102a99 upstream.
It may happen that VF spawned for E610 adapter has problem with setting link up. This happens when ixgbevf supporting mailbox API 1.6 cooperates with PF driver which doesn't support this version of API, and hence doesn't support new approach for getting PF link data.
In that case VF asks PF to provide link data but as PF doesn't support it, returns -EOPNOTSUPP what leads to early bail from link configuration sequence.
Avoid such situation by using legacy VFLINKS approach whenever negotiated API version is less than 1.6.
To reproduce the issue just create VF and set its link up - adapter must be any from the E610 family, ixgbevf must support API 1.6 or higher while ixgbevf must not.
--- drivers/net/ethernet/intel/ixgbevf/vf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbevf/vf.c +2 -1
@@ -852,7 +852,8 @@ static s32 ixgbevf_check_mac_link_vf(strif (!mac->get_link_status) goto out; -if (hw->mac.type == ixgbe_mac_e610_vf) { +if (hw->mac.type == ixgbe_mac_e610_vf && + hw->api_version >= ixgbe_mbox_api_16) { ret_val =ixgbevf_get_pf_link_state (hw, speed, link_up);if (ret_val) goto out;
Greg Kroah-Hartman
maintainerPATCH 314/567 staging: rtl8723bs: properly validate the data in rtw_get_ie_ex()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit f0109b9d3e1e455429279d602f6276e34689750a upstream.
Just like in commit 154828bf9559 ("staging: rtl8723bs: fix out-of-bounds read in rtw_get_ie() parser"), we don't trust the data in the frame so we should check the length better before acting on it
--- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/staging/rtl8723bs/core/rtw_ieee80211.c +10 -5
@@ -186,20 +186,25 @@ u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len cnt =0 ; -while (cnt < in_len) { +while (cnt +2 <= in_len) { +u8 ie_len = in_ie[cnt +1 ]; + +if (cnt +2 + ie_len > in_len) +break ; +if (eid == in_ie[cnt] - && (!oui || !memcmp (&in_ie[cnt+2 ], oui, oui_len))) { + && (!oui || (ie_len >= oui_len && !memcmp (&in_ie[cnt +2 ], oui, oui_len)))) { target_ie = &in_ie[cnt];if (ie) -memcpy (ie, &in_ie[cnt], in_ie[cnt+1 ]+2 ); +memcpy (ie, &in_ie[cnt], ie_len +2 );if (ielen) - *ielen = in_ie[cnt+1 ]+2 ; + *ielen = ie_len +2 ;break ; } - cnt += in_ie[cnt+1 ]+2 ;/* goto next */ + cnt += ie_len +2 ;/* goto next */ }return target_ie;
Greg Kroah-Hartman
maintainerPATCH 315/567 staging: rtl8723bs: fix potential out-of-bounds read in rtw_restruct_wmm_ie
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luka Gejak <[email protected]>
commit a75281626fc8fa6dc6c9cc314ee423e8bc45203b upstream.
The current code checks 'i + 5 < in_len' at the end of the if statement. However, it accesses 'in_ie[i + 5]' before that check, which can lead to an out-of-bounds read. Move the length check to the beginning of the conditional to ensure the index is within bounds before accessing the array.
--- drivers/staging/rtl8723bs/core/rtw_mlme.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/rtl8723bs/core/rtw_mlme.c +4 -1
@@ -2000,7 +2000,10 @@ int rtw_restruct_wmm_ie(struct adapter *while (i < in_len) { ielength = initial_out_len; -if (in_ie[i] ==0xDD && in_ie[i+2 ] ==0x00 && in_ie[i+3 ] ==0x50 && in_ie[i+4 ] ==0xF2 && in_ie[i+5 ] ==0x02 && i+5 < in_len) {/* WMM element ID and OUI */ +if (i +5 < in_len && + in_ie[i] ==0xDD && in_ie[i +2 ] ==0x00 && + in_ie[i +3 ] ==0x50 && in_ie[i +4 ] ==0xF2 && + in_ie[i +5 ] ==0x02 ) {for (j = i; j < i +9 ; j++) { out_ie[ielength] = in_ie[j]; ielength++;
Greg Kroah-Hartman
maintainerPATCH 316/567 media: dvb-net: fix OOB access in ULE extension header tables
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ariel Silver <[email protected]>
commit 24d87712727a5017ad142d63940589a36cd25647 upstream.
The ule_mandatory_ext_handlers[] and ule_optional_ext_handlers[] tables in handle_one_ule_extension() are declared with 255 elements (valid indices 0-254), but the index htype is derived from network-controlled data as (ule_sndu_type & 0x00FF), giving a range of 0-255. When htype equals 255, an out-of-bounds read occurs on the function pointer table, and the OOB value may be called as a function pointer.
Add a bounds check on htype against the array size before either table is accessed. Out-of-range values now cause the SNDU to be discarded.
--- drivers/media/dvb-core/dvb_net.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/dvb-core/dvb_net.c +3 -0
@@ -228,6 +228,9 @@ static int handle_one_ule_extension( strunsigned char hlen = (p->ule_sndu_type &0x0700 ) >>8 ;unsigned char htype = p->ule_sndu_type &0x00FF ; +if (htype >=ARRAY_SIZE (ule_mandatory_ext_handlers)) +return -1 ; +/* Discriminate mandatory and optional extension headers. */ if (hlen ==0 ) {/* Mandatory extension header */
Greg Kroah-Hartman
maintainerPATCH 317/567 net: mana: Ring doorbell at 4 CQ wraparounds
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Long Li <[email protected]>
commit dabffd08545ffa1d7183bc45e387860984025291 upstream.
MANA hardware requires at least one doorbell ring every 8 wraparounds of the CQ. The driver rings the doorbell as a form of flow control to inform hardware that CQEs have been consumed.
The NAPI poll functions mana_poll_tx_cq() and mana_poll_rx_cq() can poll up to CQE_POLLING_BUFFER (512) completions per call. If the CQ has fewer than 512 entries, a single poll call can process more than 4 wraparounds without ringing the doorbell. The doorbell threshold check also uses ">" instead of ">=", delaying the ring by one extra CQE beyond 4 wraparounds. Combined, these issues can cause the driver to exceed the 8-wraparound hardware limit, leading to missed completions and stalled queues.
Fix this by capping the number of CQEs polled per call to 4 wraparounds of the CQ in both TX and RX paths. Also change the doorbell threshold from ">" to ">=" so the doorbell is rung as soon as 4 wraparounds are reached.
--- drivers/net/ethernet/microsoft/mana/mana_en.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
drivers/net/ethernet/microsoft/mana/mana_en.c +18 -5
@@ -1368,8 +1368,14 @@ static void mana_poll_tx_cq(struct mana_ ndev = txq->ndev; apc =netdev_priv (ndev); +/* Limit CQEs polled to 4 wraparounds of the CQ to ensure the +* doorbell can be rung in time for the hardware's requirement +* of at least one doorbell ring every 8 wraparounds. +*/ comp_read =mana_gd_poll_cq (cq->gdma_cq, completions, -CQE_POLLING_BUFFER ); +min ((cq->gdma_cq->queue_size / +COMP_ENTRY_SIZE ) *4 , +CQE_POLLING_BUFFER ));if (comp_read <1 )return ;
@@ -1749,7 +1755,14 @@ static void mana_poll_rx_cq(struct mana_struct mana_rxq *rxq = cq->rxq;int comp_read, i; - comp_read =mana_gd_poll_cq (cq->gdma_cq, comp,CQE_POLLING_BUFFER ); +/* Limit CQEs polled to 4 wraparounds of the CQ to ensure the +* doorbell can be rung in time for the hardware's requirement +* of at least one doorbell ring every 8 wraparounds. +*/ + comp_read =mana_gd_poll_cq (cq->gdma_cq, comp, +min ((cq->gdma_cq->queue_size / +COMP_ENTRY_SIZE ) *4 , +CQE_POLLING_BUFFER ));WARN_ON_ONCE (comp_read >CQE_POLLING_BUFFER ); rxq->xdp_flush = false;
@@ -1794,11 +1807,11 @@ static int mana_cq_handler(void *contextmana_gd_ring_cq (gdma_queue,SET_ARM_BIT ); cq->work_done_since_doorbell =0 ;napi_complete_done (&cq->napi, w); - }else if (cq->work_done_since_doorbell > - cq->gdma_cq->queue_size /COMP_ENTRY_SIZE *4 ) { + }else if (cq->work_done_since_doorbell >= + (cq->gdma_cq->queue_size /COMP_ENTRY_SIZE ) *4 ) {/* MANA hardware requires at least one doorbell ring every 8 * wraparounds of CQ even if there is no need to arm the CQ. -* This driver rings the doorbell as soon as we have exceeded +* This driver rings the doorbell as soon as it has processed * 4 wraparounds. */ mana_gd_ring_cq (gdma_queue,0 );
Greg Kroah-Hartman
maintainerPATCH 318/567 ice: fix retry for AQ command 0x06EE
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Staniszewski <[email protected]>
commit fb4903b3354aed4a2301180cf991226f896c87ed upstream.
Executing ethtool -m can fail reporting a netlink I/O error while firmware link management holds the i2c bus used to communicate with the module.
According to Intel(R) Ethernet Controller E810 Datasheet Rev 2.8 [1] Section 3.3.10.4 Read/Write SFF EEPROM (0x06EE)
request should to be retried upon receiving EBUSY from firmware.
Commit e9c9692c8a81 ("ice: Reimplement module reads used by ethtool") implemented it only for part of ice_get_module_eeprom(), leaving all other calls to ice_aq_sff_eeprom() vulnerable to returning early on getting EBUSY without retrying.
Remove the retry loop from ice_get_module_eeprom() and add Admin Queue (AQ) command with opcode 0x06EE to the list of commands that should be retried on receiving EBUSY from firmware.
--- drivers/net/ethernet/intel/ice/ice_common.c | 1 drivers/net/ethernet/intel/ice/ice_ethtool.c | 35 ++++++++++----------------- 2 files changed, 15 insertions(+), 21 deletions(-)
drivers/net/ethernet/intel/ice/ice_common.c +1 -0
@@ -1611,6 +1611,7 @@ static bool ice_should_retry_sq_send_cmdcase ice_aqc_opc_lldp_stop:case ice_aqc_opc_lldp_start:case ice_aqc_opc_lldp_filter_ctrl: +case ice_aqc_opc_sff_eeprom:return true; }
drivers/net/ethernet/intel/ice/ice_ethtool.c +14 -21
@@ -4045,7 +4045,7 @@ ice_get_module_eeprom(struct net_devicestruct ice_pf *pf = vsi->back;struct ice_hw *hw = &pf->hw;bool is_sfp = false; -unsigned int i, j; +unsigned int i;u16 offset =0 ;u8 page =0 ;int status;
@@ -4087,26 +4087,19 @@ ice_get_module_eeprom(struct net_deviceif (page ==0 || !(data[0x2 ] &0x4 )) {u32 copy_len; -/* If i2c bus is busy due to slow page change or -* link management access, call can fail. This is normal. -* So we retry this a few times. -*/ -for (j =0 ; j <4 ; j++) { - status =ice_aq_sff_eeprom (hw,0 , addr, offset, page, - !is_sfp, value, -SFF_READ_BLOCK_SIZE , -0 ,NULL ); -netdev_dbg (netdev,"SFF %02X %02X %02X %X = %02X%02X%02X%02X.%02X%02X%02X%02X (%X)\n" , - addr, offset, page, is_sfp, - value[0 ], value[1 ], value[2 ], value[3 ], - value[4 ], value[5 ], value[6 ], value[7 ], - status); -if (status) { -usleep_range (1500 ,2500 ); -memset (value,0 ,SFF_READ_BLOCK_SIZE ); -continue ; - } -break ; + status =ice_aq_sff_eeprom (hw,0 , addr, offset, page, + !is_sfp, value, +SFF_READ_BLOCK_SIZE , +0 ,NULL ); +netdev_dbg (netdev,"SFF %02X %02X %02X %X = %02X%02X%02X%02X.%02X%02X%02X%02X (%pe)\n" , + addr, offset, page, is_sfp, + value[0 ], value[1 ], value[2 ], value[3 ], + value[4 ], value[5 ], value[6 ], value[7 ], +ERR_PTR (status)); +if (status) { +netdev_err (netdev,"%s: error reading module EEPROM: status %pe\n" , + __func__,ERR_PTR (status)); +return status; }/* Make sure we have enough room for the new block */
Greg Kroah-Hartman
maintainerPATCH 319/567 tracing: Fix syscall events activation by ensuring refcount hits zero
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huiwen He <[email protected]>
commit 0a663b764dbdf135a126284f454c9f01f95a87d4 upstream.
When multiple syscall events are specified in the kernel command line (e.g., trace_event=syscalls:sys_enter_openat,syscalls:sys_enter_close), they are often not captured after boot, even though they appear enabled in the tracing/set_event file.
The issue stems from how syscall events are initialized. Syscall tracepoints require the global reference count (sys_tracepoint_refcount) to transition from 0 to 1 to trigger the registration of the syscall work (TIF_SYSCALL_TRACEPOINT) for tasks, including the init process (pid 1).
The current implementation of early_enable_events() with disable_first=true used an interleaved sequence of "Disable A -> Enable A -> Disable B -> Enable B". If multiple syscalls are enabled, the refcount never drops to zero, preventing the 0->1 transition that triggers actual registration.
Fix this by splitting early_enable_events() into two distinct phases:
1. Disable all events specified in the buffer.
2. Enable all events specified in the buffer.
This ensures the refcount hits zero before re-enabling, allowing syscall events to be properly activated during early boot.
The code is also refactored to use a helper function to avoid logic duplication between the disable and enable phases.
--- kernel/trace/trace_events.c | 52 +++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 15 deletions(-)
kernel/trace/trace_events.c +37 -15
@@ -4140,26 +4140,22 @@ static __init int event_trace_memsetup(vreturn 0 ; } -__init void -early_enable_events (struct trace_array *tr,char *buf,bool disable_first) +/* +* Helper function to enable or disable a comma-separated list of events +* from the bootup buffer. +*/ +static __init void __early_set_events (struct trace_array *tr,char *buf,bool enable) {char *token; -int ret; - -while (true) { - token =strsep (&buf,"," ); - -if (!token) -break ; +while ((token =strsep (&buf,"," ))) {if (*token) { -/* Restarting syscalls requires that we stop them first */ -if (disable_first) +if (enable) { +if (ftrace_set_clr_event (tr, token,1 )) +pr_warn ("Failed to enable trace event: %s\n" , token); + }else {ftrace_set_clr_event (tr, token,0 ); - - ret =ftrace_set_clr_event (tr, token,1 ); -if (ret) -pr_warn ("Failed to enable trace event: %s\n" , token); + } }/* Put back the comma to allow this to be called again */
@@ -4168,6 +4164,32 @@ early_enable_events(struct trace_array * } } +/** +* early_enable_events - enable events from the bootup buffer +* @tr: The trace array to enable the events in +* @buf: The buffer containing the comma separated list of events +* @disable_first: If true, disable all events in @buf before enabling them +* +* This function enables events from the bootup buffer. If @disable_first +* is true, it will first disable all events in the buffer before enabling +* them. +* +* For syscall events, which rely on a global refcount to register the +* SYSCALL_WORK_SYSCALL_TRACEPOINT flag (especially for pid 1), we must +* ensure the refcount hits zero before re-enabling them. A simple +* "disable then enable" per-event is not enough if multiple syscalls are +* used, as the refcount will stay above zero. Thus, we need a two-phase +* approach: disable all, then enable all. +*/ +__init void +early_enable_events (struct trace_array *tr,char *buf,bool disable_first) +{ +if (disable_first) +__early_set_events (tr, buf, false); + +__early_set_events (tr, buf, true); +} +static __init int event_trace_enable (void ) {struct trace_array *tr =top_trace_array ();
Greg Kroah-Hartman
maintainerPATCH 320/567 batman-adv: Avoid double-rtnl_lock ELP metric worker
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit cfc83a3c71517b59c1047db57da31e26a9dc2f33 upstream.
batadv_v_elp_get_throughput() might be called when the RTNL lock is already held. This could be problematic when the work queue item is cancelled via cancel_delayed_work_sync() in batadv_v_elp_iface_disable(). In this case, an rtnl_lock() would cause a deadlock.
To avoid this, rtnl_trylock() was used in this function to skip the retrieval of the ethtool information in case the RTNL lock was already held.
But for cfg80211 interfaces, batadv_get_real_netdev() was called - which also uses rtnl_lock(). The approach for __ethtool_get_link_ksettings() must also be used instead and the lockless version __batadv_get_real_netdev() has to be called.
--- net/batman-adv/bat_v_elp.c | 10 +++++++++- net/batman-adv/hard-interface.c | 8 ++++---- net/batman-adv/hard-interface.h | 1 + 3 files changed, 14 insertions(+), 5 deletions(-)
net/batman-adv/bat_v_elp.c +9 -1
@@ -112,7 +112,15 @@ static bool batadv_v_elp_get_throughput(/* unsupported WiFi driver version */ goto default_throughput; - real_netdev =batadv_get_real_netdev (hard_iface->net_dev); +/* only use rtnl_trylock because the elp worker will be cancelled while +* the rntl_lock is held. the cancel_delayed_work_sync() would otherwise +* wait forever when the elp work_item was started and it is then also +* trying to rtnl_lock +*/ +if (!rtnl_trylock ()) +return false; + real_netdev =__batadv_get_real_netdev (hard_iface->net_dev); +rtnl_unlock ();if (!real_netdev) goto default_throughput;
net/batman-adv/hard-interface.c +4 -4
@@ -203,7 +203,7 @@ static bool batadv_is_valid_iface(const }/** -* batadv_get_real_netdevice() - check if the given netdev struct is a virtual +* __batadv_get_real_netdev() - check if the given netdev struct is a virtual * interface on top of another 'real' interface * @netdev: the device to check *
@@ -213,7 +213,7 @@ static bool batadv_is_valid_iface(const* Return: the 'real' net device or the original net device and NULL in case * of an error. */ -static struct net_device *batadv_get_real_netdevice (struct net_device *netdev) +struct net_device *__batadv_get_real_netdev (struct net_device *netdev) {struct batadv_hard_iface *hard_iface =NULL ;struct net_device *real_netdev =NULL ;
@@ -266,7 +266,7 @@ struct net_device *batadv_get_real_netdestruct net_device *real_netdev;rtnl_lock (); - real_netdev =batadv_get_real_netdevice (net_device); + real_netdev =__batadv_get_real_netdev (net_device);rtnl_unlock ();return real_netdev;
@@ -335,7 +335,7 @@ static u32 batadv_wifi_flags_evaluate(stif (batadv_is_cfg80211_netdev (net_device)) wifi_flags |=BATADV_HARDIF_WIFI_CFG80211_DIRECT ; - real_netdev =batadv_get_real_netdevice (net_device); + real_netdev =__batadv_get_real_netdev (net_device);if (!real_netdev)return wifi_flags;
net/batman-adv/hard-interface.h +1 -0
@@ -68,6 +68,7 @@ enum batadv_hard_if_bcast {extern struct notifier_block batadv_hard_if_notifier; +struct net_device *__batadv_get_real_netdev (struct net_device *net_device);struct net_device *batadv_get_real_netdev (struct net_device *net_device);bool batadv_is_cfg80211_hardif (struct batadv_hard_iface *hard_iface);bool batadv_is_wifi_hardif (struct batadv_hard_iface *hard_iface);
Greg Kroah-Hartman
maintainerPATCH 321/567 parisc: Increase initial mapping to 64 MB with KALLSYMS
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit 8e732934fb81282be41602550e7e07baf265e972 upstream.
The 32MB initial kernel mapping can become too small when CONFIG_KALLSYMS is used. Increase the mapping to 64 MB in this case.
--- arch/parisc/include/asm/pgtable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/parisc/include/asm/pgtable.h +1 -1
@@ -85,7 +85,7 @@ extern void __update_cache(pte_t pte);printk ("%s:%d: bad pgd %08lx.\n" , __FILE__, __LINE__, (unsigned long )pgd_val (e)) /* This is the size of the initially mapped kernel memory */ -#if defined(CONFIG_64BIT ) +#if defined(CONFIG_64BIT ) || defined(CONFIG_KALLSYMS )#define KERNEL_INITIAL_ORDER 26/* 1<<26 = 64MB */ #else #define KERNEL_INITIAL_ORDER 25/* 1<<25 = 32MB */
Greg Kroah-Hartman
maintainerPATCH 322/567 nouveau/dpcd: return EBUSY for aux xfer if the device is asleep
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Airlie <[email protected]>
commit 8f3c6f08ababad2e3bdd239728cf66a9949446b4 upstream.
If we have runtime suspended, and userspace wants to use /dev/drm_dp_* then just tell it the device is busy instead of crashing in the GSP code.
WARNING: CPU: 2 PID: 565741 at drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/rpc.c:164 r535_gsp_msgq_wait+0x9a/0xb0 [nouveau] CPU: 2 UID: 0 PID: 565741 Comm: fwupd Not tainted 6.18.10-200.fc43.x86_64 #1 PREEMPT(lazy) Hardware name: LENOVO 20QTS0PQ00/20QTS0PQ00, BIOS N2OET65W (1.52 ) 08/05/2024 RIP: 0010:r535_gsp_msgq_wait+0x9a/0xb0 [nouveau]
This is a simple fix to get backported. We should probably engineer a proper power domain solution to wake up devices and keep them awake while fw updates are happening.
--- drivers/gpu/drm/nouveau/nouveau_connector.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/nouveau/nouveau_connector.c +3 -0
@@ -1212,6 +1212,9 @@ nouveau_connector_aux_xfer(struct drm_dpu8 size = msg->size;int ret; +if (pm_runtime_suspended (nv_connector->base.dev->dev)) +return -EBUSY ; + nv_encoder =find_encoder (&nv_connector->base,DCB_OUTPUT_DP );if (!nv_encoder || !(aux = nv_encoder->aux))return -ENODEV ;
Greg Kroah-Hartman
maintainerPATCH 323/567 arm64: mm: Add PTE_DIRTY back to PAGE_KERNEL* to fix kexec/hibernation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Catalin Marinas <[email protected]>
commit c25c4aa3f79a488cc270507935a29c07dc6bddfc upstream.
Commit 143937ca51cc ("arm64, mm: avoid always making PTE dirty in pte_mkwrite()") changed pte_mkwrite_novma() to only clear PTE_RDONLY when PTE_DIRTY is set. This was to allow writable-clean PTEs for swap pages that haven't actually been written.
However, this broke kexec and hibernation for some platforms. Both go through trans_pgd_create_copy() -> _copy_pte(), which calls pte_mkwrite_novma() to make the temporary linear-map copy fully writable. With the updated pte_mkwrite_novma(), read-only kernel pages (without PTE_DIRTY) remain read-only in the temporary mapping. While such behaviour is fine for user pages where hardware DBM or trapping will make them writeable, subsequent in-kernel writes by the kexec relocation code will fault.
Add PTE_DIRTY back to all _PAGE_KERNEL* protection definitions. This was the case prior to 5.4, commit aa57157be69f ("arm64: Ensure VM_WRITE|VM_SHARED ptes are clean by default"). With the kernel linear-map PTEs always having PTE_DIRTY set, pte_mkwrite_novma() correctly clears PTE_RDONLY.
--- arch/arm64/include/asm/pgtable-prot.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/arm64/include/asm/pgtable-prot.h +5 -5
@@ -45,11 +45,11 @@#define _PAGE_DEFAULT (_PROT_DEFAULT | PTE_ATTRINDX(MT_NORMAL)) -#define _PAGE_KERNEL (PROT_NORMAL) -#define _PAGE_KERNEL_RO ((PROT_NORMAL & ~PTE_WRITE) | PTE_RDONLY) -#define _PAGE_KERNEL_ROX ((PROT_NORMAL & ~(PTE_WRITE | PTE_PXN)) | PTE_RDONLY) -#define _PAGE_KERNEL_EXEC (PROT_NORMAL & ~PTE_PXN) -#define _PAGE_KERNEL_EXEC_CONT ((PROT_NORMAL & ~PTE_PXN) | PTE_CONT) +#define _PAGE_KERNEL (PROT_NORMAL | PTE_DIRTY) +#define _PAGE_KERNEL_RO ((PROT_NORMAL & ~PTE_WRITE) | PTE_RDONLY | PTE_DIRTY) +#define _PAGE_KERNEL_ROX ((PROT_NORMAL & ~(PTE_WRITE | PTE_PXN)) | PTE_RDONLY | PTE_DIRTY) +#define _PAGE_KERNEL_EXEC ((PROT_NORMAL & ~PTE_PXN) | PTE_DIRTY) +#define _PAGE_KERNEL_EXEC_CONT ((PROT_NORMAL & ~PTE_PXN) | PTE_CONT | PTE_DIRTY)#define _PAGE_SHARED (_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_UXN | PTE_WRITE)#define _PAGE_SHARED_EXEC (_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_WRITE)
Greg Kroah-Hartman
maintainerPATCH 324/567 hwmon: (pmbus/q54sj108a2) fix stack overflow in debugfs read
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sanman Pradhan <[email protected]>
commit 25dd70a03b1f5f3aa71e1a5091ecd9cd2a13ee43 upstream.
The q54sj108a2_debugfs_read function suffers from a stack buffer overflow due to incorrect arguments passed to bin2hex(). The function currently passes 'data' as the destination and 'data_char' as the source.
Because bin2hex() converts each input byte into two hex characters, a 32-byte block read results in 64 bytes of output. Since 'data' is only 34 bytes (I2C_SMBUS_BLOCK_MAX + 2), this writes 30 bytes past the end of the buffer onto the stack.
Additionally, the arguments were swapped: it was reading from the zero-initialized 'data_char' and writing to 'data', resulting in all-zero output regardless of the actual I2C read.
Fix this by:
1. Expanding 'data_char' to 66 bytes to safely hold the hex output.
2. Correcting the bin2hex() argument order and using the actual read count.
3. Using a pointer to select the correct output buffer for the final simple_read_from_buffer call.
--- drivers/hwmon/pmbus/q54sj108a2.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/hwmon/pmbus/q54sj108a2.c +10 -9
@@ -78,7 +78,8 @@ static ssize_t q54sj108a2_debugfs_read(sint idx = *idxp;struct q54sj108a2_data *psu =to_psu (idxp, idx);char data[I2C_SMBUS_BLOCK_MAX +2 ] = {0 }; -char data_char[I2C_SMBUS_BLOCK_MAX +2 ] = {0 }; +char data_char[I2C_SMBUS_BLOCK_MAX *2 +2 ] = {0 }; +char *out = data;char *res;switch (idx) {
@@ -149,27 +150,27 @@ static ssize_t q54sj108a2_debugfs_read(sif (rc <0 )return rc; - res =bin2hex (data, data_char,32 ); - rc = res - data; - + res =bin2hex (data_char, data, rc); + rc = res - data_char; + out = data_char;break ;case Q54SJ108A2_DEBUGFS_FLASH_KEY : rc =i2c_smbus_read_block_data (psu->client,PMBUS_FLASH_KEY_WRITE , data);if (rc <0 )return rc; - res =bin2hex (data, data_char,4 ); - rc = res - data; - + res =bin2hex (data_char, data, rc); + rc = res - data_char; + out = data_char;break ;default :return -EINVAL ; } - data[rc] ='\n' ; + out[rc] ='\n' ; rc +=2 ; -return simple_read_from_buffer (buf, count, ppos, data, rc); +return simple_read_from_buffer (buf, count, ppos, out, rc); } static ssize_t q54sj108a2_debugfs_write(struct file *file, const char __user *buf,
Greg Kroah-Hartman
maintainerPATCH 325/567 parisc: Fix initial page table creation for boot
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit 8475d8fe21ec9c7eb2faca555fbc5b68cf0d2597 upstream.
The KERNEL_INITIAL_ORDER value defines the initial size (usually 32 or 64 MB) of the page table during bootup. Up until now the whole area was initialized with PTE entries, but there was no check if we filled too many entries. Change the code to fill up with so many entries that the "_end" symbol can be reached by the kernel, but not more entries than actually fit into the initial PTE tables.
--- arch/parisc/kernel/head.S | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/parisc/kernel/head.S +6 -1
@@ -56,6 +56,7 @@ ENTRY(parisc_kernel_start) .import __bss_start,data .import __bss_stop,data + .import __end,data load32 PA(__bss_start),%r3 load32 PA(__bss_stop),%r4
@@ -149,7 +150,11 @@ $cpu_ok: * everything ... it will get remapped correctly later */ ldo 0+_PAGE_KERNEL_RWX(%r0),%r3 /* Hardwired 0 phys addr start */ load32 (1<<(KERNEL_INITIAL_ORDER-PAGE_SHIFT)),%r11 /* PFN count */ - load32 PA(pg0),%r1 + load32 PA(_end),%r1 + SHRREG %r1,PAGE_SHIFT,%r1 /* %r1 is PFN count for _end symbol */ + cmpb,<<,n %r11,%r1,1f + copy %r1,%r11 /* %r1 PFN count smaller than %r11 */ +1: load32 PA(pg0),%r1 $pgt_fill_loop: STREGM %r3,ASM_PTE_ENTRY_SIZE(%r1)
Greg Kroah-Hartman
maintainerPATCH 326/567 parisc: Check kernel mapping earlier at bootup
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit 17c144f1104bfc29a3ce3f7d0931a1bfb7a3558c upstream.
The check if the initial mapping is sufficient needs to happen much earlier during bootup. Move this test directly to the start_parisc() function and use native PDC iodc functions to print the warning, because panic() and printk() are not functional yet.
This fixes boot when enabling various KALLSYSMS options which need much more space.
--- arch/parisc/kernel/setup.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
arch/parisc/kernel/setup.c +12 -8
@@ -123,14 +123,6 @@ void __init setup_arch(char **cmdline_p)#endif printk (KERN_CONT ".\n" ); -/* -* Check if initial kernel page mappings are sufficient. -* panic early if not, else we may access kernel functions -* and variables which can't be reached. -*/ -if (__pa ((unsigned long ) &_end) >=KERNEL_INITIAL_SIZE ) -panic ("KERNEL_INITIAL_ORDER too small!" ); -#ifdef CONFIG_64BIT if (parisc_narrow_firmware) {printk (KERN_INFO "Kernel is using PDC in 32-bit mode.\n" );
@@ -282,6 +274,18 @@ void __init start_parisc(void)int ret, cpunum;struct pdc_coproc_cfg coproc_cfg; +/* +* Check if initial kernel page mapping is sufficient. +* Print warning if not, because we may access kernel functions and +* variables which can't be reached yet through the initial mappings. +* Note that the panic() and printk() functions are not functional +* yet, so we need to use direct iodc() firmware calls instead. +*/ +const char warn1[] ="CRITICAL: Kernel may crash because " +"KERNEL_INITIAL_ORDER is too small.\n" ; +if (__pa ((unsigned long ) &_end) >=KERNEL_INITIAL_SIZE ) +pdc_iodc_print (warn1,sizeof (warn1) -1 ); +/* check QEMU/SeaBIOS marker in PAGE0 */ running_on_qemu = (memcmp (&PAGE0 ->pad0,"SeaBIOS" ,8 ) ==0 );
Greg Kroah-Hartman
maintainerPATCH 327/567 pmdomain: bcm: bcm2835-power: Fix broken reset status read
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <[email protected]>
commit 550bae2c0931dbb664a61b08c21cf156f0a5362a upstream.
bcm2835_reset_status() has a misplaced parenthesis on every PM_READ() call. Since PM_READ(reg) expands to readl(power->base + (reg)), the expression:
PM_READ(PM_GRAFX & PM_V3DRSTN)
computes the bitwise AND of the register offset PM_GRAFX with the bitmask PM_V3DRSTN before using the result as a register offset, reading from the wrong MMIO address instead of the intended PM_GRAFX register. The same issue affects the PM_IMAGE cases.
Fix by moving the closing parenthesis so PM_READ() receives only the register offset, and the bitmask is applied to the value returned by the read.
--- drivers/pmdomain/bcm/bcm2835-power.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pmdomain/bcm/bcm2835-power.c +3 -3
@@ -580,11 +580,11 @@ static int bcm2835_reset_status(struct rswitch (id) {case BCM2835_RESET_V3D : -return !PM_READ (PM_GRAFX &PM_V3DRSTN ); +return !(PM_READ (PM_GRAFX ) &PM_V3DRSTN );case BCM2835_RESET_H264 : -return !PM_READ (PM_IMAGE &PM_H264RSTN ); +return !(PM_READ (PM_IMAGE ) &PM_H264RSTN );case BCM2835_RESET_ISP : -return !PM_READ (PM_IMAGE &PM_ISPRSTN ); +return !(PM_READ (PM_IMAGE ) &PM_ISPRSTN );default :return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 328/567 ksmbd: fix use-after-free in smb_lazy_parent_lease_break_close()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
commit eac3361e3d5dd8067b3258c69615888eb45e9f25 upstream.
opinfo pointer obtained via rcu_dereference(fp->f_opinfo) is being accessed after rcu_read_unlock() has been called. This creates a race condition where the memory could be freed by a concurrent writer between the unlock and the subsequent pointer dereferences (opinfo->is_lease, etc.), leading to a use-after-free.
--- fs/smb/server/oplock.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/smb/server/oplock.c +4 -2
@@ -1123,10 +1123,12 @@ void smb_lazy_parent_lease_break_close(srcu_read_lock (); opinfo =rcu_dereference (fp->f_opinfo); -rcu_read_unlock (); -if (!opinfo || !opinfo->is_lease || opinfo->o_lease->version !=2 ) +if (!opinfo || !opinfo->is_lease || opinfo->o_lease->version !=2 ) { +rcu_read_unlock ();return ; + } +rcu_read_unlock (); p_ci =ksmbd_inode_lookup_lock (fp->filp->f_path.dentry->d_parent);if (!p_ci)
Greg Kroah-Hartman
maintainerPATCH 329/567 smb: server: fix use-after-free in smb2_open()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marios Makassikis <[email protected]>
commit 1e689a56173827669a35da7cb2a3c78ed5c53680 upstream.
The opinfo pointer obtained via rcu_dereference(fp->f_opinfo) is dereferenced after rcu_read_unlock(), creating a use-after-free window.
--- fs/smb/server/smb2pdu.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/smb/server/smb2pdu.c +2 -3
@@ -3593,10 +3593,8 @@ int smb2_open(struct ksmbd_work *work) reconnected_fp: rsp->StructureSize =cpu_to_le16 (89 ); -rcu_read_lock (); - opinfo =rcu_dereference (fp->f_opinfo); + opinfo =opinfo_get (fp); rsp->OplockLevel = opinfo !=NULL ? opinfo->level :0 ; -rcu_read_unlock (); rsp->Flags =0 ; rsp->CreateAction =cpu_to_le32 (file_info); rsp->CreationTime =cpu_to_le64 (fp->create_time);
@@ -3637,6 +3635,7 @@ reconnected_fp: next_ptr = &lease_ccontext->Next; next_off = conn->vals->create_lease_size; } +opinfo_put (opinfo);if (maximal_access_ctxt) {struct create_context *mxac_ccontext;
Greg Kroah-Hartman
maintainerPATCH 330/567 ksmbd: fix use-after-free by using call_rcu() for oplock_info
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
commit 1dfd062caa165ec9d7ee0823087930f3ab8a6294 upstream.
ksmbd currently frees oplock_info immediately using kfree(), even though it is accessed under RCU read-side critical sections in places like opinfo_get() and proc_show_files().
Since there is no RCU grace period delay between nullifying the pointer and freeing the memory, a reader can still access oplock_info structure after it has been freed. This can leads to a use-after-free especially in opinfo_get() where atomic_inc_not_zero() is called on already freed memory.
Fix this by switching to deferred freeing using call_rcu().
--- fs/smb/server/oplock.c | 29 +++++++++++++++++++++-------- fs/smb/server/oplock.h | 5 +++-- 2 files changed, 24 insertions(+), 10 deletions(-)
fs/smb/server/oplock.c +21 -8
@@ -120,7 +120,7 @@ static void free_lease(struct oplock_infkfree (lease); } -static void free_opinfo (struct oplock_info *opinfo) +static void __free_opinfo (struct oplock_info *opinfo) {if (opinfo->is_lease)free_lease (opinfo);
@@ -129,6 +129,18 @@ static void free_opinfo(struct oplock_inkfree (opinfo); } +static void free_opinfo_rcu (struct rcu_head *rcu) +{ + struct oplock_info *opinfo = container_of(rcu, struct oplock_info, rcu); + +__free_opinfo (opinfo); +} + +static void free_opinfo (struct oplock_info *opinfo) +{ +call_rcu (&opinfo->rcu, free_opinfo_rcu); +} +struct oplock_info *opinfo_get (struct ksmbd_file *fp) {struct oplock_info *opinfo;
@@ -176,9 +188,9 @@ void opinfo_put(struct oplock_info *opinfree_opinfo (opinfo); } -static void opinfo_add (struct oplock_info *opinfo) +static void opinfo_add (struct oplock_info *opinfo,struct ksmbd_file *fp) { -struct ksmbd_inode *ci = opinfo->o_fp->f_ci; +struct ksmbd_inode *ci = fp->f_ci;down_write (&ci->m_lock);list_add (&opinfo->op_entry, &ci->m_op_list);
@@ -1279,20 +1291,21 @@ set_lev:set_oplock_level (opinfo, req_op_level, lctx); out: -rcu_assign_pointer (fp->f_opinfo, opinfo); - opinfo->o_fp = fp; -opinfo_count_inc (fp); -opinfo_add (opinfo); +opinfo_add (opinfo, fp); +if (opinfo->is_lease) { err =add_lease_global_list (opinfo);if (err) goto err_out; } +rcu_assign_pointer (fp->f_opinfo, opinfo); + opinfo->o_fp = fp; +return 0 ; err_out: -free_opinfo (opinfo); +__free_opinfo (opinfo);return err; }
fs/smb/server/oplock.h +3 -2
@@ -76,8 +76,9 @@ struct oplock_info {struct lease *o_lease;struct list_head op_entry;struct list_head lease_entry; -wait_queue_head_t oplock_q;/* Other server threads */ -wait_queue_head_t oplock_brk;/* oplock breaking wait */ +wait_queue_head_t oplock_q;/* Other server threads */ +wait_queue_head_t oplock_brk;/* oplock breaking wait */ +struct rcu_head rcu; };struct lease_break_info {
Greg Kroah-Hartman
maintainerPATCH 331/567 net: ncsi: fix skb leak in error paths
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jian Zhang <[email protected]>
commit 5c3398a54266541610c8d0a7082e654e9ff3e259 upstream.
Early return paths in NCSI RX and AEN handlers fail to release the received skb, resulting in a memory leak.
Specifically, ncsi_aen_handler() returns on invalid AEN packets without consuming the skb. Similarly, ncsi_rcv_rsp() exits early when failing to resolve the NCSI device, response handler, or request, leaving the skb unfreed.
--- net/ncsi/ncsi-aen.c | 3 ++- net/ncsi/ncsi-rsp.c | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-)
net/ncsi/ncsi-aen.c +2 -1
@@ -224,7 +224,8 @@ int ncsi_aen_handler(struct ncsi_dev_priif (!nah) {netdev_warn (ndp->ndev.dev,"Invalid AEN (0x%x) received\n" , h->type); -return -ENOENT ; + ret = -ENOENT ; + goto out; } ret =ncsi_validate_aen_pkt (h, nah->payload);
net/ncsi/ncsi-rsp.c +12 -4
@@ -1176,8 +1176,10 @@ int ncsi_rcv_rsp(struct sk_buff *skb, st/* Find the NCSI device */ nd =ncsi_find_dev (orig_dev); ndp = nd ?TO_NCSI_DEV_PRIV (nd) :NULL ; -if (!ndp) -return -ENODEV ; +if (!ndp) { + ret = -ENODEV ; + goto err_free_skb; + }/* Check if it is AEN packet */ hdr = (struct ncsi_pkt_hdr *)skb_network_header (skb);
@@ -1199,7 +1201,8 @@ int ncsi_rcv_rsp(struct sk_buff *skb, stif (!nrh) {netdev_err (nd->dev,"Received unrecognized packet (0x%x)\n" , hdr->type); -return -ENOENT ; + ret = -ENOENT ; + goto err_free_skb; }/* Associate with the request */
@@ -1207,7 +1210,8 @@ int ncsi_rcv_rsp(struct sk_buff *skb, st nr = &ndp->requests[hdr->id];if (!nr->used) {spin_unlock_irqrestore (&ndp->lock, flags); -return -ENODEV ; + ret = -ENODEV ; + goto err_free_skb; } nr->rsp = skb;
@@ -1261,4 +1265,8 @@ out_netlink: out:ncsi_free_request (nr);return ret; + +err_free_skb: +kfree_skb (skb); +return ret; }
Greg Kroah-Hartman
maintainerPATCH 332/567 net: ethernet: arc: emac: quiesce interrupts before requesting IRQ
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
commit 2503d08f8a2de618e5c3a8183b250ff4a2e2d52c upstream.
Normal RX/TX interrupts are enabled later, in arc_emac_open(), so probe should not see interrupt delivery in the usual case. However, hardware may still present stale or latched interrupt status left by firmware or the bootloader.
If probe later unwinds after devm_request_irq() has installed the handler, such a stale interrupt can still reach arc_emac_intr() during teardown and race with release of the associated net_device.
Avoid that window by putting the device into a known quiescent state before requesting the IRQ: disable all EMAC interrupt sources and clear any pending EMAC interrupt status bits. This keeps the change hardware-focused and minimal, while preventing spurious IRQ delivery from leftover state.
--- drivers/net/ethernet/arc/emac_main.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/net/ethernet/arc/emac_main.c +11 -0
@@ -934,6 +934,17 @@ int arc_emac_probe(struct net_device *nd/* Set poll rate so that it polls every 1 ms */ arc_reg_set (priv,R_POLLRATE , clock_frequency /1000000 ); +/* +* Put the device into a known quiescent state before requesting +* the IRQ. Clear only EMAC interrupt status bits here; leave the +* MDIO completion bit alone and avoid writing TXPL_MASK, which is +* used to force TX polling rather than acknowledge interrupts. +*/ +arc_reg_set (priv,R_ENABLE ,0 ); +arc_reg_set (priv,R_STATUS ,RXINT_MASK |TXINT_MASK |ERR_MASK | +TXCH_MASK |MSER_MASK |RXCR_MASK | +RXFR_MASK |RXFL_MASK ); + ndev->irq = irq;dev_info (dev,"IRQ is %d\n" , ndev->irq);
Greg Kroah-Hartman
maintainerPATCH 333/567 net: dsa: microchip: Fix error path in PTP IRQ setup
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bastien Curutchet (Schneider Electric) <[email protected]>
commit 99c8c16a4aad0b37293cae213e15957c573cf79b upstream.
If request_threaded_irq() fails during the PTP message IRQ setup, the newly created IRQ mapping is never disposed. Indeed, the ksz_ptp_irq_setup()'s error path only frees the mappings that were successfully set up.
Dispose the newly created mapping if the associated request_threaded_irq() fails at setup.
--- drivers/net/dsa/microchip/ksz_ptp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/dsa/microchip/ksz_ptp.c +8 -3
@@ -1101,6 +1101,7 @@ static int ksz_ptp_msg_irq_setup(structconst struct ksz_dev_ops *ops = port->ksz_dev->dev_ops;struct ksz_irq *ptpirq = &port->ptpirq;struct ksz_ptp_irq *ptpmsg_irq; +int ret; ptpmsg_irq = &port->ptpmsg_irq[n]; ptpmsg_irq->num =irq_create_mapping (ptpirq->domain, n);
@@ -1112,9 +1113,13 @@ static int ksz_ptp_msg_irq_setup(structsnprintf (ptpmsg_irq->name,sizeof (ptpmsg_irq->name), name[n]); -return request_threaded_irq (ptpmsg_irq->num,NULL , - ksz_ptp_msg_thread_fn,IRQF_ONESHOT , - ptpmsg_irq->name, ptpmsg_irq); + ret =request_threaded_irq (ptpmsg_irq->num,NULL , + ksz_ptp_msg_thread_fn,IRQF_ONESHOT , + ptpmsg_irq->name, ptpmsg_irq); +if (ret) +irq_dispose_mapping (ptpmsg_irq->num); + +return ret; }int ksz_ptp_irq_setup (struct dsa_switch *ds,u8 p)
Greg Kroah-Hartman
maintainerPATCH 334/567 drm/amdgpu: Fix use-after-free race in VM acquire
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alysa Liu <[email protected]>
commit 2c1030f2e84885cc58bffef6af67d5b9d2e7098f upstream.
Replace non-atomic vm->process_info assignment with cmpxchg() to prevent race when parent/child processes sharing a drm_file both try to acquire the same VM after fork().
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +5 -1
@@ -1351,7 +1351,10 @@ static int init_kfd_vm(struct amdgpu_vm *ef =dma_fence_get (&info->eviction_fence->base); } - vm->process_info = *process_info; +if (cmpxchg (&vm->process_info,NULL , *process_info) !=NULL ) { + ret = -EINVAL ; + goto already_acquired; + }/* Validate page directory and attach eviction fence */ ret =amdgpu_bo_reserve (vm->root.bo, true);
@@ -1389,6 +1392,7 @@ validate_pd_fail:amdgpu_bo_unreserve (vm->root.bo); reserve_pd_fail: vm->process_info =NULL ; +already_acquired:if (info) {/* Two fence references: one in info and one in *ef */ dma_fence_put (&info->eviction_fence->base);
Greg Kroah-Hartman
maintainerPATCH 335/567 drm/amd: Set num IP blocks to 0 if discovery fails
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
commit 3646ff28780b4c52c5b5081443199e7a430110e5 upstream.
If discovery has failed for any reason (such as no support for a block) then there is no need to unwind all the IP blocks in fini. In this condition there can actually be failures during the unwind too.
Reset num_ip_blocks to zero during failure path and skip the unnecessary cleanup path.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +++- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -1
@@ -2096,8 +2096,10 @@ static int amdgpu_device_ip_early_init(sbreak ;default : r =amdgpu_discovery_set_ip_blocks (adev); -if (r) +if (r) { + adev->num_ip_blocks =0 ;return r; + }break ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1 -1
@@ -82,7 +82,7 @@ void amdgpu_driver_unload_kms(struct drm {struct amdgpu_device *adev =drm_to_adev (dev); -if (adev ==NULL ) +if (adev ==NULL || !adev->num_ip_blocks)return ;amdgpu_unregister_gpu_instance (adev);
Greg Kroah-Hartman
maintainerPATCH 336/567 drm/bridge: ti-sn65dsi83: fix CHA_DSI_CLK_RANGE rounding
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Ceresoli <[email protected]>
commit 2f22702dc0fee06a240404e0f7ead5b789b253d8 upstream.
The DSI frequency must be in the range:
(CHA_DSI_CLK_RANGE * 5 MHz) <= DSI freq < ((CHA_DSI_CLK_RANGE + 1) * 5 MHz)
So the register value should point to the lower range value, but DIV_ROUND_UP() rounds the division to the higher range value, resulting in an excess of 1 (unless the frequency is an exact multiple of 5 MHz).
For example for a 437100000 MHz clock CHA_DSI_CLK_RANGE should be 87 (0x57):
(87 * 5 = 435) <= 437.1 < (88 * 5 = 440)
but current code returns 88 (0x58).
Fix the computation by removing the DIV_ROUND_UP().
--- drivers/gpu/drm/bridge/ti-sn65dsi83.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/ti-sn65dsi83.c +3 -3
@@ -303,9 +303,9 @@ static u8 sn65dsi83_get_dsi_range(struct* DSI_CLK = mode clock * bpp / dsi_data_lanes / 2 * the 2 is there because the bus is DDR. */ -return DIV_ROUND_UP (clamp ((unsigned int )mode->clock * -mipi_dsi_pixel_format_to_bpp (ctx->dsi->format) / - ctx->dsi->lanes /2 ,40000U ,500000U ),5000U ); +return clamp ((unsigned int )mode->clock * +mipi_dsi_pixel_format_to_bpp (ctx->dsi->format) / + ctx->dsi->lanes /2 ,40000U ,500000U ) /5000U ; }static u8 sn65dsi83_get_dsi_div (struct sn65dsi83 *ctx)
Greg Kroah-Hartman
maintainerPATCH 337/567 drm/i915: Fix potential overflow of shmem scatterlist length
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Janusz Krzysztofik <[email protected]>
commit 029ae067431ab9d0fca479bdabe780fa436706ea upstream.
When a scatterlists table of a GEM shmem object of size 4 GB or more is populated with pages allocated from a folio, unsigned int .length attribute of a scatterlist may get overflowed if total byte length of pages allocated to that single scatterlist happens to reach or cross the 4GB limit. As a consequence, users of the object may suffer from hitting unexpected, premature end of the object's backing pages.
[278.780187] ------------[ cut here ]------------ [278.780377] WARNING: CPU: 1 PID: 2326 at drivers/gpu/drm/i915/i915_mm.c:55 remap_sg+0x199/0x1d0 [i915] ... [278.780654] CPU: 1 UID: 0 PID: 2326 Comm: gem_mmap_offset Tainted: G S U 6.17.0-rc1-CI_DRM_16981-ged823aaa0607+ #1 PREEMPT(voluntary) [278.780656] Tainted: [S]=CPU_OUT_OF_SPEC, [U]=USER [278.780658] Hardware name: Intel Corporation Meteor Lake Client Platform/MTL-P LP5x T3 RVP, BIOS MTLPFWI1.R00.3471.D91.2401310918 01/31/2024 [278.780659] RIP: 0010:remap_sg+0x199/0x1d0 [i915] ... [278.780786] Call Trace: [278.780787] <TASK> [278.780788] ? __apply_to_page_range+0x3e6/0x910 [278.780795] ? __pfx_remap_sg+0x10/0x10 [i915] [278.780906] apply_to_page_range+0x14/0x30 [278.780908] remap_io_sg+0x14d/0x260 [i915] [278.781013] vm_fault_cpu+0xd2/0x330 [i915] [278.781137] __do_fault+0x3a/0x1b0 [278.781140] do_fault+0x322/0x640 [278.781143] __handle_mm_fault+0x938/0xfd0 [278.781150] handle_mm_fault+0x12c/0x300 [278.781152] ? lock_mm_and_find_vma+0x4b/0x760 [278.781155] do_user_addr_fault+0x2d6/0x8e0 [278.781160] exc_page_fault+0x96/0x2c0 [278.781165] asm_exc_page_fault+0x27/0x30
...
That issue was apprehended by the author of a change that introduced it, and potential risk even annotated with a comment, but then never addressed.
When adding folio pages to a scatterlist table, take care of byte length of any single scatterlist not exceeding max_segment.
--- drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_shmem.c +9 -3
@@ -151,8 +151,12 @@ int shmem_sg_alloc_table(struct drm_i915 } }while (1 ); - nr_pages = min_t(unsigned long, -folio_nr_pages (folio), page_count - i); + nr_pages =min_array (((unsigned long []) { +folio_nr_pages (folio), + page_count - i, + max_segment /PAGE_SIZE , + }),3 ); +if (!i || sg->length >= max_segment ||folio_pfn (folio) != next_pfn) {
@@ -162,7 +166,9 @@ int shmem_sg_alloc_table(struct drm_i915 st->nents++;sg_set_folio (sg, folio, nr_pages *PAGE_SIZE ,0 ); }else { -/* XXX: could overflow? */ + nr_pages = min_t(unsigned long, nr_pages, + (max_segment - sg->length) /PAGE_SIZE ); + sg->length += nr_pages *PAGE_SIZE ; } next_pfn =folio_pfn (folio) + nr_pages;
Greg Kroah-Hartman
maintainerPATCH 338/567 tracing: Fix trace_buf_size= cmdline parameter with sizes >= 2G
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Calvin Owens <[email protected]>
commit d008ba8be8984760e36d7dcd4adbd5a41a645708 upstream.
Some of the sizing logic through tracer_alloc_buffers() uses int internally, causing unexpected behavior if the user passes a value that does not fit in an int (on my x86 machine, the result is uselessly tiny buffers).
Fix by plumbing the parameter's real type (unsigned long) through to the ring buffer allocation functions, which already use unsigned long.
It has always been possible to create larger ring buffers via the sysfs
interface: this only affects the cmdline parameter.
--- kernel/trace/trace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/trace/trace.c +3 -3
@@ -9271,7 +9271,7 @@ static void init_tracer_tracefs(struct trace_array *tr, struct dentry *d_tracer);static int -allocate_trace_buffer (struct trace_array *tr,struct array_buffer *buf,int size) +allocate_trace_buffer (struct trace_array *tr,struct array_buffer *buf,unsigned long size) {enum ring_buffer_flags rb_flags;
@@ -9307,7 +9307,7 @@ static void free_trace_buffer(struct arr } } -static int allocate_trace_buffers (struct trace_array *tr,int size) +static int allocate_trace_buffers (struct trace_array *tr,unsigned long size) {int ret;
@@ -10330,7 +10330,7 @@ __init static void enable_instances(void__init static int tracer_alloc_buffers (void ) { -int ring_buf_size; +unsigned long ring_buf_size;int ret = -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 339/567 cifs: make default value of retrans as zero
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shyam Prasad N <[email protected]>
commit e3beefd3af09f8e460ddaf39063d3d7664d7ab59 upstream.
When retrans mount option was introduced, the default value was set as 1. However, in the light of some bugs that this has exposed recently we should change it to 0 and retain the old behaviour before this option was introduced.
--- fs/smb/client/fs_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/client/fs_context.c +1 -1
@@ -1809,7 +1809,7 @@ int smb3_init_fs_context(struct fs_conte ctx->backupuid_specified = false;/* no backup intent for a user */ ctx->backupgid_specified = false;/* no backup intent for a group */ - ctx->retrans =1 ; + ctx->retrans =0 ; ctx->reparse_type =CIFS_REPARSE_TYPE_DEFAULT ;/*
Greg Kroah-Hartman
maintainerPATCH 340/567 xfs: fix undersized l_iclog_roundoff values
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
commit 52a8a1ba883defbfe3200baa22cf4cd21985d51a upstream.
If the superblock doesn't list a log stripe unit, we set the incore log roundoff value to 512. This leads to corrupt logs and unmountable filesystems in generic/617 on a disk with 4k physical sectors...
XFS (sda1): Mounting V5 Filesystem ff3121ca-26e6-4b77-b742-aaff9a449e1c
XFS (sda1): Torn write (CRC failure) detected at log block 0x318e. Truncating head block from 0x3197. XFS (sda1): failed to locate log tail
XFS (sda1): log mount/recovery failed: error -74
XFS (sda1): log mount failed
XFS (sda1): Mounting V5 Filesystem ff3121ca-26e6-4b77-b742-aaff9a449e1c
XFS (sda1): Ending clean mount
...on the current xfsprogs for-next which has a broken mkfs. xfs_info shows this...
meta-data=/dev/sda1 isize=512 agcount=4, agsize=644992 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=1
= reflink=1 bigtime=1 inobtcount=1 nrext64=1
= exchange=1 metadir=1
data = bsize=4096 blocks=2579968, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1, parent=1
log =internal log bsize=4096 blocks=16384, version=2
= sectsz=4096 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
= rgcount=0 rgsize=268435456 extents
= zoned=0 start=0 reserved=0...observe that the log section has sectsz=4096 sunit=0, which means that the roundoff factor is 512, not 4096 as you'd expect. We should fix mkfs not to generate broken filesystems, but anyone can fuzz the ondisk superblock so we should be more cautious. I think the inadequate logic predates commit a6a65fef5ef8d0, but that's clearly going to require a different backport.
--- fs/xfs/xfs_log.c | 2 ++ 1 file changed, 2 insertions(+)
fs/xfs/xfs_log.c +2 -0
@@ -1552,6 +1552,8 @@ xlog_alloc_log(if (xfs_has_logv2 (mp) && mp->m_sb.sb_logsunit >1 ) log->l_iclog_roundoff = mp->m_sb.sb_logsunit; +else if (mp->m_sb.sb_logsectsize >0 ) + log->l_iclog_roundoff = mp->m_sb.sb_logsectsize;else log->l_iclog_roundoff =BBSIZE ;
Greg Kroah-Hartman
maintainerPATCH 341/567 s390/dasd: Move quiesce state with pprc swap
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Haberland <[email protected]>
commit 40e9cd4ae8ec43b107ed2bff422a8fa39dcf4e4b upstream.
Quiesce and resume is a mechanism to suspend operations on DASD devices. In the context of a controlled copy pair swap operation, the quiesce operation is usually issued before the actual swap and a resume afterwards.
During the swap operation, the underlying device is exchanged. Therefore, the quiesce flag must be moved to the secondary device to ensure a consistent quiesce state after the swap.
The secondary device itself cannot be suspended separately because there is no separate block device representation for it.
--- drivers/s390/block/dasd_eckd.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/s390/block/dasd_eckd.c +5 -0
@@ -6232,6 +6232,11 @@ static int dasd_eckd_copy_pair_swap(stru dev_name(&secondary->cdev->dev), rc); } +if (primary->stopped &DASD_STOPPED_QUIESCE ) { +dasd_device_set_stop_bits (secondary,DASD_STOPPED_QUIESCE ); +dasd_device_remove_stop_bits (primary,DASD_STOPPED_QUIESCE ); + } +/* re-enable device */ dasd_device_remove_stop_bits (primary,DASD_STOPPED_PPRC );dasd_device_remove_stop_bits (secondary,DASD_STOPPED_PPRC );
Greg Kroah-Hartman
maintainerPATCH 342/567 s390/dasd: Copy detected format information to secondary device
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Haberland <[email protected]>
commit 4c527c7e030672efd788d0806d7a68972a7ba3c1 upstream.
During online processing for a DASD device an IO operation is started to determine the format of the device. CDL format contains specifically sized blocks at the beginning of the disk.
For a PPRC secondary device no real IO operation is possible therefore this IO request can not be started and this step is skipped for online processing of secondary devices. This is generally fine since the secondary is a copy of the primary device.
In case of an additional partition detection that is run after a swap operation the format information is needed to properly drive partition detection IO.
Currently the information is not passed leading to IO errors during partition detection and a wrongly detected partition table which in turn might lead to data corruption on the disk with the wrong partition table.
Fix by passing the format information from primary to secondary device.
--- drivers/s390/block/dasd_eckd.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/s390/block/dasd_eckd.c +11 -0
@@ -6185,6 +6185,7 @@ static void copy_pair_set_active(structstatic int dasd_eckd_copy_pair_swap (struct dasd_device *device,char *prim_busid,char *sec_busid) { +struct dasd_eckd_private *prim_priv, *sec_priv;struct dasd_device *primary, *secondary;struct dasd_copy_relation *copy;struct dasd_block *block;
@@ -6205,6 +6206,9 @@ static int dasd_eckd_copy_pair_swap(struif (!secondary)return DASD_COPYPAIRSWAP_SECONDARY ; + prim_priv = primary->private; + sec_priv = secondary->private; +/* * usually the device should be quiesced for swap * for paranoia stop device and requeue requests again
@@ -6237,6 +6241,13 @@ static int dasd_eckd_copy_pair_swap(strudasd_device_remove_stop_bits (primary,DASD_STOPPED_QUIESCE ); } +/* +* The secondary device never got through format detection, but since it +* is a copy of the primary device, the format is exactly the same; +* therefore, the detected layout can simply be copied. +*/ + sec_priv->uses_cdl = prim_priv->uses_cdl; +/* re-enable device */ dasd_device_remove_stop_bits (primary,DASD_STOPPED_PPRC );dasd_device_remove_stop_bits (secondary,DASD_STOPPED_PPRC );
Greg Kroah-Hartman
maintainerPATCH 343/567 lib/bootconfig: fix off-by-one in xbc_verify_tree() unclosed brace error
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Law <[email protected]>
commit 39ebc8d7f561e1b64eca87353ef9b18e2825e591 upstream.
__xbc_open_brace() pushes entries with post-increment (open_brace[brace_index++]), so brace_index always points one past the last valid entry. xbc_verify_tree() reads open_brace[brace_index] to report which brace is unclosed, but this is one past the last pushed entry and contains stale/zero data, causing the error message to reference the wrong node.
Use open_brace[brace_index - 1] to correctly identify the unclosed brace. brace_index is known to be > 0 here since we are inside the if (brace_index) guard.
--- lib/bootconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bootconfig.c +1 -1
@@ -793,7 +793,7 @@ static int __init xbc_verify_tree(void)/* Brace closing */ if (brace_index) { - n = &xbc_nodes[open_brace[brace_index]]; + n = &xbc_nodes[open_brace[brace_index -1 ]];return xbc_parse_error ("Brace is not closed" ,xbc_node_get_data (n)); }
Greg Kroah-Hartman
maintainerPATCH 344/567 scsi: core: Fix error handling for scsi_alloc_sdev()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junxiao Bi <[email protected]>
commit 4ce7ada40c008fa21b7e52ab9d04e8746e2e9325 upstream.
After scsi_sysfs_device_initialize() was called, error paths must call __scsi_remove_device().
--- drivers/scsi/scsi_scan.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/scsi/scsi_scan.c +2 -6
@@ -353,12 +353,8 @@ static struct scsi_device *scsi_alloc_sd* default device queue depth to figure out sbitmap shift * since we use this queue depth most of times. */ -if (scsi_realloc_sdev_budget_map (sdev, depth)) { -kref_put (&sdev->host->tagset_refcnt, scsi_mq_free_tags); -put_device (&starget->dev); -kfree (sdev); - goto out; - } +if (scsi_realloc_sdev_budget_map (sdev, depth)) + goto out_device_destroy;scsi_change_queue_depth (sdev, depth);
Greg Kroah-Hartman
maintainerPATCH 345/567 x86/apic: Disable x2apic on resume if the kernel expects so
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shashank Balaji <[email protected]>
commit 8cc7dd77a1466f0ec58c03478b2e735a5b289b96 upstream.
When resuming from s2ram, firmware may re-enable x2apic mode, which may have been disabled by the kernel during boot either because it doesn't support IRQ remapping or for other reasons. This causes the kernel to continue using the xapic interface, while the hardware is in x2apic mode, which causes hangs. This happens on defconfig + bare metal + s2ram.
Fix this in lapic_resume() by disabling x2apic if the kernel expects it to be disabled, i.e. when x2apic_mode = 0.
The ACPI v6.6 spec, Section 16.3 [1] says firmware restores either the pre-sleep configuration or initial boot configuration for each CPU, including MSR state:
When executing from the power-on reset vector as a result of waking from an S2 or S3 sleep state, the platform firmware performs only the hardware initialization required to restore the system to either the state the platform was in prior to the initial operating system boot, or to the pre-sleep configuration state. In multiprocessor systems, non-boot processors should be placed in the same state as prior to the initial operating system boot.
(further ahead)
If this is an S2 or S3 wake, then the platform runtime firmware restores minimum context of the system before jumping to the waking vector. This includes:
CPU configuration. Platform runtime firmware restores the pre-sleep configuration or initial boot configuration of each CPU (MSR, MTRR, firmware update, SMBase, and so on). Interrupts must be disabled (for IA-32 processors, disabled by CLI instruction).
(and other things)
So at least as per the spec, re-enablement of x2apic by the firmware is allowed if "x2apic on" is a part of the initial boot configuration.
[1] https://uefi.org/specs/ACPI/6.6/16_Waking_and_Sleeping.html#initialization
[ bp: Massage. ]
--- arch/x86/kernel/apic/apic.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/x86/kernel/apic/apic.c +6 -0
@@ -1931,6 +1931,7 @@ void __init check_x2apic(void)static inline void try_to_enable_x2apic (int remap_mode) { }static inline void __x2apic_enable (void ) { } +static inline void __x2apic_disable (void ) { }#endif /* !CONFIG_X86_X2APIC */ void __init enable_IR_x2apic (void )
@@ -2652,6 +2653,11 @@ static void lapic_resume(void)if (x2apic_mode) {__x2apic_enable (); }else { +if (x2apic_enabled ()) { +pr_warn_once ("x2apic: re-enabled by firmware during resume. Disabling\n" ); +__x2apic_disable (); + } +/* * Make sure the APICBASE points to the right address *
Greg Kroah-Hartman
maintainerPATCH 346/567 lib/bootconfig: fix snprintf truncation check in xbc_node_compose_key_after()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Law <[email protected]>
commit 1120a36bb1e9b9e22de75ecb4ef0b998f73a97f1 upstream.
snprintf() returns the number of characters that would have been written excluding the NUL terminator. Output is truncated when the return value is >= the buffer size, not just > the buffer size.
When ret == size, the current code takes the non-truncated path, advancing buf by ret and reducing size to 0. This is wrong because the output was actually truncated (the last character was replaced by NUL). Fix by using >= so the truncation path is taken correctly.
--- lib/bootconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bootconfig.c +1 -1
@@ -318,7 +318,7 @@ int __init xbc_node_compose_key_after(st depth ? "." : "");if (ret <0 )return ret; -if (ret > size) { +if (ret >= size) { size =0 ; }else { size -= ret;
Greg Kroah-Hartman
maintainerPATCH 347/567 lib/bootconfig: check bounds before writing in __xbc_open_brace()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Law <[email protected]>
commit 560f763baa0f2c9a44da4294c06af071405ac46f upstream.
The bounds check for brace_index happens after the array write. While the current call pattern prevents an actual out-of-bounds access (the previous call would have returned an error), the write-before-check pattern is fragile and would become a real out-of-bounds write if the error return were ever not propagated.
Move the bounds check before the array write so the function is self-contained and safe regardless of caller behavior.
--- lib/bootconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bootconfig.c +1 -1
@@ -534,9 +534,9 @@ static char *skip_spaces_until_newline(cstatic int __init __xbc_open_brace (char *p) {/* Push the last key as open brace */ - open_brace[brace_index++] =xbc_node_index (last_parent);if (brace_index >=XBC_DEPTH_MAX )return xbc_parse_error ("Exceed max depth of braces" , p); + open_brace[brace_index++] =xbc_node_index (last_parent);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 348/567 smb: client: fix atomic open with O_DIRECT & O_SYNC
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <[email protected]>
commit 4a7d2729dc99437dbb880a64c47828c0d191b308 upstream.
When user application requests O_DIRECT|O_SYNC along with O_CREAT on open(2), CREATE_NO_BUFFER and CREATE_WRITE_THROUGH bits were missed in CREATE request when performing an atomic open, thus leading to potentially data integrity issues.
Fix this by setting those missing bits in CREATE request when O_DIRECT|O_SYNC has been specified in cifs_do_create().
--- fs/smb/client/cifsglob.h | 11 +++++++++++ fs/smb/client/dir.c | 1 + fs/smb/client/file.c | 18 +++--------------- 3 files changed, 15 insertions(+), 15 deletions(-)
fs/smb/client/cifsglob.h +11 -0
@@ -20,6 +20,7 @@#include <linux/utsname.h> #include <linux/sched/mm.h> #include <linux/netfs.h> +#include <linux/fcntl.h> #include "cifs_fs_sb.h" #include "cifsacl.h" #include <crypto/internal/hash.h>
@@ -2354,4 +2355,14 @@ static inline bool cifs_ses_exiting(stru return ret; } +static inline int cifs_open_create_options (unsigned int oflags,int opts) +{ +/* O_SYNC also has bit for O_DSYNC so following check picks up either */ +if (oflags &O_SYNC ) + opts |=CREATE_WRITE_THROUGH ; +if (oflags &O_DIRECT ) + opts |=CREATE_NO_BUFFER ; +return opts; +} +#endif /* _CIFS_GLOB_H */
fs/smb/client/dir.c +1 -0
@@ -304,6 +304,7 @@ static int cifs_do_create(struct inode * goto out; } + create_options |=cifs_open_create_options (oflags, create_options);/* * if we're not using unix extensions, see if we need to set * ATTR_READONLY on the create call
fs/smb/client/file.c +3 -15
@@ -459,15 +459,8 @@ static int cifs_nt_open(const char *full*********************************************************************/ disposition =cifs_get_disposition (f_flags); -/* BB pass O_SYNC flag through on file attributes .. BB */ - -/* O_SYNC also has bit for O_DSYNC so following check picks up either */ -if (f_flags &O_SYNC ) - create_options |=CREATE_WRITE_THROUGH ; - -if (f_flags &O_DIRECT ) - create_options |=CREATE_NO_BUFFER ; + create_options |=cifs_open_create_options (f_flags, create_options); retry_open: oparms = (struct cifs_open_parms ) {
@@ -1117,13 +1110,8 @@ cifs_reopen_file(struct cifsFileInfo *cf rdwr_for_fscache =1 ; desired_access =cifs_convert_flags (cfile->f_flags, rdwr_for_fscache); - -/* O_SYNC also has bit for O_DSYNC so following check picks up either */ -if (cfile->f_flags &O_SYNC ) - create_options |=CREATE_WRITE_THROUGH ; - -if (cfile->f_flags &O_DIRECT ) - create_options |=CREATE_NO_BUFFER ; + create_options |=cifs_open_create_options (cfile->f_flags, + create_options);if (server->ops->get_lease_key) server->ops->get_lease_key (inode, &cfile->fid);
Greg Kroah-Hartman
maintainerPATCH 349/567 smb: client: fix in-place encryption corruption in SMB2_write()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bharath SM <[email protected]>
commit d78840a6a38d312dc1a51a65317bb67e46f0b929 upstream.
SMB2_write() places write payload in iov[1..n] as part of rq_iov. smb3_init_transform_rq() pointer-shares rq_iov, so crypt_message() encrypts iov[1] in-place, replacing the original plaintext with ciphertext. On a replayable error, the retry sends the same iov[1] which now contains ciphertext instead of the original data, resulting in corruption.
The corruption is most likely to be observed when connections are unstable, as reconnects trigger write retries that re-send the already-encrypted data.
This affects SFU mknod, MF symlinks, etc. On kernels before 6.10 (prior to the netfs conversion), sync writes also used this path and were similarly affected. The async write path wasn't unaffected as it uses rq_iter which gets deep-copied.
Fix by moving the write payload into rq_iter via iov_iter_kvec(), so smb3_init_transform_rq() deep-copies it before encryption.
--- fs/smb/client/smb2pdu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/smb/client/smb2pdu.c +4 -1
@@ -5073,7 +5073,10 @@ replay_again:memset (&rqst,0 ,sizeof (struct smb_rqst )); rqst.rq_iov = iov; - rqst.rq_nvec = n_vec +1 ; +/* iov[0] is the SMB header; move payload to rq_iter for encryption safety */ + rqst.rq_nvec =1 ; +iov_iter_kvec (&rqst.rq_iter,ITER_SOURCE , &iov[1 ], n_vec, + io_parms->length);if (retries)smb2_set_replay (server, &rqst);
Greg Kroah-Hartman
maintainerPATCH 350/567 smb: client: fix iface port assignment in parse_server_interfaces
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henrique Carvalho <[email protected]>
commit d4c7210d2f3ea481a6481f03040a64d9077a6172 upstream.
parse_server_interfaces() initializes interface socket addresses with CIFS_PORT. When the mount uses a non-default port this overwrites the configured destination port.
Later, cifs_chan_update_iface() copies this sockaddr into server->dstaddr, causing reconnect attempts to use the wrong port after server interface updates.
Use the existing port from server->dstaddr instead.
--- fs/smb/client/smb2ops.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
fs/smb/client/smb2ops.c +12 -2
@@ -586,6 +586,7 @@ parse_server_interfaces(struct network_istruct iface_info_ipv6 *p6;struct cifs_server_iface *info =NULL , *iface =NULL , *niface =NULL ;struct cifs_server_iface tmp_iface; +__be16 port;ssize_t bytes_left;size_t next =0 ;int nb_iface =0 ;
@@ -620,6 +621,15 @@ parse_server_interfaces(struct network_i goto out; } +spin_lock (&ses->server->srv_lock); +if (ses->server->dstaddr.ss_family ==AF_INET ) + port = ((struct sockaddr_in *)&ses->server->dstaddr)->sin_port; +else if (ses->server->dstaddr.ss_family ==AF_INET6 ) + port = ((struct sockaddr_in6 *)&ses->server->dstaddr)->sin6_port; +else + port =cpu_to_be16 (CIFS_PORT ); +spin_unlock (&ses->server->srv_lock); +while (bytes_left >= (ssize_t )sizeof (*p)) {memset (&tmp_iface,0 ,sizeof (tmp_iface));/* default to 1Gbps when link speed is unset */
@@ -640,7 +650,7 @@ parse_server_interfaces(struct network_imemcpy (&addr4->sin_addr, &p4->IPv4Address,4 );/* [MS-SMB2] 2.2.32.5.1.1 Clients MUST ignore these */ - addr4->sin_port =cpu_to_be16 (CIFS_PORT ); + addr4->sin_port = port;cifs_dbg (FYI ,"%s: ipv4 %pI4\n" , __func__, &addr4->sin_addr);
@@ -654,7 +664,7 @@ parse_server_interfaces(struct network_i/* [MS-SMB2] 2.2.32.5.1.2 Clients MUST ignore these */ addr6->sin6_flowinfo =0 ; addr6->sin6_scope_id =0 ; - addr6->sin6_port =cpu_to_be16 (CIFS_PORT ); + addr6->sin6_port = port;cifs_dbg (FYI ,"%s: ipv6 %pI6\n" , __func__, &addr6->sin6_addr);
Greg Kroah-Hartman
maintainerPATCH 351/567 btrfs: abort transaction on failure to update root in the received subvol ioctl
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 0f475ee0ebce5c9492b260027cd95270191675fa upstream.
If we failed to update the root we don't abort the transaction, which is wrong since we already used the transaction to remove an item from the uuid tree.
--- fs/btrfs/ioctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/ioctl.c +2 -1
@@ -4037,7 +4037,8 @@ static long _btrfs_ioctl_set_received_su ret =btrfs_update_root (trans, fs_info->tree_root, &root->root_key, &root->root_item); -if (ret <0 ) { +if (unlikely (ret <0 )) { +btrfs_abort_transaction (trans, ret);btrfs_end_transaction (trans); goto out; }
Greg Kroah-Hartman
maintainerPATCH 352/567 iio: dac: ds4424: reject -128 RAW value
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleksij Rempel <[email protected]>
commit 5187e03b817c26c1c3bcb2645a612ea935c4be89 upstream.
The DS442x DAC uses sign-magnitude encoding, so -128 cannot be represented in hardware (7-bit magnitude).
Previously, passing -128 resulted in a truncated value that programmed 0mA (magnitude 0) instead of the expected maximum negative current, effectively failing silently.
Reject -128 to avoid producing the wrong current.
--- drivers/iio/dac/ds4424.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/dac/ds4424.c +1 -1
@@ -141,7 +141,7 @@ static int ds4424_write_raw(struct iio_dswitch (mask) {case IIO_CHAN_INFO_RAW : -if (val <S8_MIN || val >S8_MAX ) +if (val <=S8_MIN || val >S8_MAX )return -EINVAL ;if (val >0 ) {
Greg Kroah-Hartman
maintainerPATCH 353/567 iio: frequency: adf4377: Fix duplicated soft reset mask
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeungJu Cheon <[email protected]>
commit 6c8bf4b604a8a6346ca71f1c027fa01c2c2e04cb upstream.
The regmap_read_poll_timeout() uses ADF4377_0000_SOFT_RESET_R_MSK twice instead of checking both SOFT_RESET_MSK (bit 0) and SOFT_RESET_R_MSK (bit 7). This causes an incomplete reset status check.
The code first sets both SOFT_RESET and SOFT_RESET_R bits to 1 via regmap_update_bits(), then polls for them to be cleared. Since we set both bits before polling, we should be waiting for both to clear.
Fix by using both masks as done in regmap_update_bits() above.
--- drivers/iio/frequency/adf4377.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/frequency/adf4377.c +1 -1
@@ -495,7 +495,7 @@ static int adf4377_soft_reset(struct adfreturn ret;return regmap_read_poll_timeout (st->regmap,0x0 , read_val, - !(read_val & (ADF4377_0000_SOFT_RESET_R_MSK | + !(read_val & (ADF4377_0000_SOFT_RESET_MSK |ADF4377_0000_SOFT_RESET_R_MSK )),200 ,200 *100 ); }
Greg Kroah-Hartman
maintainerPATCH 354/567 iio: chemical: sps30_serial: fix buffer size in sps30_serial_read_meas()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoniu Miclaus <[email protected]>
commit c3914ce1963c4db25e186112c90fa5d2361e9e0a upstream.
sizeof(num) evaluates to sizeof(size_t) which is 8 bytes on 64-bit, but the buffer elements are only 4 bytes. The same function already uses sizeof(*meas) on line 312, making the mismatch evident. Use sizeof(*meas) consistently.
--- drivers/iio/chemical/sps30_serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/chemical/sps30_serial.c +1 -1
@@ -303,7 +303,7 @@ static int sps30_serial_read_meas(structif (msleep_interruptible (1000 ))return -EINTR ; - ret =sps30_serial_command (state,SPS30_SERIAL_READ_MEAS ,NULL ,0 , meas, num *sizeof (num)); + ret =sps30_serial_command (state,SPS30_SERIAL_READ_MEAS ,NULL ,0 , meas, num *sizeof (*meas));if (ret <0 )return ret;/* if measurements aren't ready sensor returns empty frame */
Greg Kroah-Hartman
maintainerPATCH 355/567 iio: chemical: sps30_i2c: fix buffer size in sps30_i2c_read_meas()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoniu Miclaus <[email protected]>
commit 216345f98cae7fcc84f49728c67478ac00321c87 upstream.
sizeof(num) evaluates to sizeof(size_t) (8 bytes on 64-bit) instead of the intended __be32 element size (4 bytes). Use sizeof(*meas) to correctly match the buffer element type.
--- drivers/iio/chemical/sps30_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/chemical/sps30_i2c.c +1 -1
@@ -171,7 +171,7 @@ static int sps30_i2c_read_meas(struct spif (!sps30_i2c_meas_ready (state))return -ETIMEDOUT ; -return sps30_i2c_command (state,SPS30_I2C_READ_MEAS ,NULL ,0 , meas,sizeof (num) * num); +return sps30_i2c_command (state,SPS30_I2C_READ_MEAS ,NULL ,0 , meas,sizeof (*meas) * num); }static int sps30_i2c_clean_fan (struct sps30_state *state)
Greg Kroah-Hartman
maintainerPATCH 356/567 iio: potentiometer: mcp4131: fix double application of wiper shift
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Schmid <[email protected]>
commit 85e4614524dca6c0a43874f475a17de2b9725648 upstream.
The MCP4131 wiper address is shifted twice when preparing the SPI command in mcp4131_write_raw().
The address is already shifted when assigned to the local variable "address", but is then shifted again when written to data->buf[0]. This results in an incorrect command being sent to the device and breaks wiper writes to the second channel.
Remove the second shift and use the pre-shifted address directly when composing the SPI transfer.
--- drivers/iio/potentiometer/mcp4131.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/potentiometer/mcp4131.c +1 -1
@@ -222,7 +222,7 @@ static int mcp4131_write_raw(struct iio_mutex_lock (&data->lock); - data->buf[0 ] = address <<MCP4131_WIPER_SHIFT ; + data->buf[0 ] = address; data->buf[0 ] |=MCP4131_WRITE | (val >>8 ); data->buf[1 ] = val &0xFF ;/* 8 bits here */
Greg Kroah-Hartman
maintainerPATCH 357/567 iio: chemical: bme680: Fix measurement wait duration calculation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Spencer <[email protected]>
commit f55b9510cd9437da3a0efa08b089caeb47595ff1 upstream.
This function refers to the Bosch BME680 API as the source of the calculation, but one of the constants does not match the Bosch implementation. This appears to be a simple transposition of two digits, resulting in a wait time that is too short. This can cause the following 'device measurement cycle incomplete' check to occasionally fail, returning EBUSY to user space.
Adjust the constant to match the Bosch implementation and resolve the EBUSY errors.
--- drivers/iio/chemical/bme680_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/chemical/bme680_core.c +1 -1
@@ -550,7 +550,7 @@ static int bme680_wait_for_eoc(struct bm* + heater duration */ int wait_eoc_us = ((data->oversampling_temp + data->oversampling_press + - data->oversampling_humid) *1936 ) + (477 *4 ) + + data->oversampling_humid) *1963 ) + (477 *4 ) + (477 *5 ) +1000 + (data->heater_dur *1000 );usleep_range (wait_eoc_us, wait_eoc_us +100 );
Greg Kroah-Hartman
maintainerPATCH 358/567 iio: buffer: Fix wait_queue not being removed
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nuno Sá <[email protected]>
commit 064234044056c93a3719d6893e6e5a26a94a61b6 upstream.
In the edge case where the IIO device is unregistered while we're buffering, we were directly returning an error without removing the wait queue. Instead, set 'ret' and break out of the loop.
--- drivers/iio/industrialio-buffer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/iio/industrialio-buffer.c +4 -2
@@ -194,8 +194,10 @@ static ssize_t iio_buffer_write(struct f written =0 ;add_wait_queue (&rb->pollq, &wait); do { - if (!indio_dev->info) - return -ENODEV; + if (!indio_dev->info) { + ret = -ENODEV; + break; + } if (!iio_buffer_space_available(rb)) { if (signal_pending(current)) {
Greg Kroah-Hartman
maintainerPATCH 359/567 iio: gyro: mpu3050-core: fix pm_runtime error handling
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoniu Miclaus <[email protected]>
commit acc3949aab3e8094641a9c7c2768de1958c88378 upstream.
The return value of pm_runtime_get_sync() is not checked, allowing the driver to access hardware that may fail to resume. The device usage count is also unconditionally incremented. Use pm_runtime_resume_and_get() which propagates errors and avoids incrementing the usage count on failure.
In preenable, add pm_runtime_put_autosuspend() on set_8khz_samplerate() failure since postdisable does not run when preenable fails.
--- drivers/iio/gyro/mpu3050-core.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/iio/gyro/mpu3050-core.c +13 -5
@@ -322,7 +322,9 @@ static int mpu3050_read_raw(struct iio_d }case IIO_CHAN_INFO_RAW :/* Resume device */ -pm_runtime_get_sync (mpu3050->dev); + ret =pm_runtime_resume_and_get (mpu3050->dev); +if (ret) +return ret;mutex_lock (&mpu3050->lock); ret =mpu3050_set_8khz_samplerate (mpu3050);
@@ -651,14 +653,20 @@ out_trigger_unlock:static int mpu3050_buffer_preenable (struct iio_dev *indio_dev) {struct mpu3050 *mpu3050 =iio_priv (indio_dev); +int ret; -pm_runtime_get_sync (mpu3050->dev); + ret =pm_runtime_resume_and_get (mpu3050->dev); +if (ret) +return ret;/* Unless we have OUR trigger active, run at full speed */ -if (!mpu3050->hw_irq_trigger) -return mpu3050_set_8khz_samplerate (mpu3050); +if (!mpu3050->hw_irq_trigger) { + ret =mpu3050_set_8khz_samplerate (mpu3050); +if (ret) +pm_runtime_put_autosuspend (mpu3050->dev); + } -return 0 ; +return ret; }static int mpu3050_buffer_postdisable (struct iio_dev *indio_dev)
Greg Kroah-Hartman
maintainerPATCH 360/567 iio: gyro: mpu3050-i2c: fix pm_runtime error handling
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoniu Miclaus <[email protected]>
commit 91f950b4cbb1aa9ea4eb3999f1463e8044b717fb upstream.
The return value of pm_runtime_get_sync() is not checked, and the function always returns success. This allows I2C mux operations to proceed even when the device fails to resume.
Use pm_runtime_resume_and_get() and propagate its return value to properly handle resume failures.
--- drivers/iio/gyro/mpu3050-i2c.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/gyro/mpu3050-i2c.c +1 -2
@@ -19,8 +19,7 @@ static int mpu3050_i2c_bypass_select(strstruct mpu3050 *mpu3050 =i2c_mux_priv (mux);/* Just power up the device, that is all that is needed */ -pm_runtime_get_sync (mpu3050->dev); -return 0 ; +return pm_runtime_resume_and_get (mpu3050->dev); }static int mpu3050_i2c_bypass_deselect (struct i2c_mux_core *mux,u32 chan_id)
Greg Kroah-Hartman
maintainerPATCH 361/567 iio: imu: inv_icm42600: fix odr switch to the same value
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Baptiste Maneyrol <[email protected]>
commit c9f3a593137d862d424130343e77d4b5260a4f5a upstream.
ODR switch is done in 2 steps when FIFO is on : change the ODR register value and acknowledge change when reading the FIFO ODR change flag. When we are switching to the same odr value, we end up waiting for a FIFO ODR flag that is never happening.
Fix the issue by doing nothing and exiting properly when we are switching to the same ODR value.
--- drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c | 2 ++ drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c | 2 ++ 2 files changed, 4 insertions(+)
drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c +2 -0
@@ -321,6 +321,8 @@ static int inv_icm42600_accel_write_odr(return -EINVAL ; conf.odr = inv_icm42600_accel_odr_conv[idx /2 ]; +if (conf.odr == st->conf.accel.odr) +return 0 ;pm_runtime_get_sync (dev);mutex_lock (&st->lock);
drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c +2 -0
@@ -333,6 +333,8 @@ static int inv_icm42600_gyro_write_odr(sreturn -EINVAL ; conf.odr = inv_icm42600_gyro_odr_conv[idx /2 ]; +if (conf.odr == st->conf.gyro.odr) +return 0 ;pm_runtime_get_sync (dev);mutex_lock (&st->lock);
Greg Kroah-Hartman
maintainerPATCH 362/567 i3c: mipi-i3c-hci: Use ETIMEDOUT instead of ETIME for timeout errors
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
commit 4167b8914463132654e01e16259847d097f8a7f7 upstream.
The MIPI I3C HCI driver currently returns -ETIME for various timeout conditions, while other I3C master drivers consistently use -ETIMEDOUT for the same class of errors. Align the HCI driver with the rest of the subsystem by replacing all uses of -ETIME with -ETIMEDOUT.
--- drivers/i3c/master/mipi-i3c-hci/cmd_v1.c | 2 +- drivers/i3c/master/mipi-i3c-hci/cmd_v2.c | 2 +- drivers/i3c/master/mipi-i3c-hci/core.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/i3c/master/mipi-i3c-hci/cmd_v1.c +1 -1
@@ -335,7 +335,7 @@ static int hci_cmd_v1_daa(struct i3c_hci hci->io->queue_xfer (hci, xfer,1 );if (!wait_for_completion_timeout (&done,HZ ) && hci->io->dequeue_xfer (hci, xfer,1 )) { - ret = -ETIME ; + ret = -ETIMEDOUT ;break ; } if (RESP_STATUS(xfer[0].response) == RESP_ERR_NACK &&
drivers/i3c/master/mipi-i3c-hci/cmd_v2.c +1 -1
@@ -277,7 +277,7 @@ static int hci_cmd_v2_daa(struct i3c_hci hci->io->queue_xfer (hci, xfer,2 );if (!wait_for_completion_timeout (&done,HZ ) && hci->io->dequeue_xfer (hci, xfer,2 )) { - ret = -ETIME ; + ret = -ETIMEDOUT ;break ; }if (RESP_STATUS (xfer[0 ].response) !=RESP_SUCCESS ) {
drivers/i3c/master/mipi-i3c-hci/core.c +3 -3
@@ -237,7 +237,7 @@ static int i3c_hci_send_ccc_cmd(struct i goto out;if (!wait_for_completion_timeout (&done,HZ ) && hci->io->dequeue_xfer (hci, xfer, nxfers)) { - ret = -ETIME ; + ret = -ETIMEDOUT ; goto out; }for (i = prefixed; i < nxfers; i++) {
@@ -311,7 +311,7 @@ static int i3c_hci_priv_xfers(struct i3c goto out;if (!wait_for_completion_timeout (&done,HZ ) && hci->io->dequeue_xfer (hci, xfer, nxfers)) { - ret = -ETIME ; + ret = -ETIMEDOUT ; goto out; }for (i =0 ; i < nxfers; i++) {
@@ -359,7 +359,7 @@ static int i3c_hci_i2c_xfers(struct i2c_ goto out;if (!wait_for_completion_timeout (&done,HZ ) && hci->io->dequeue_xfer (hci, xfer, nxfers)) { - ret = -ETIME ; + ret = -ETIMEDOUT ; goto out; }for (i =0 ; i < nxfers; i++) {
Greg Kroah-Hartman
maintainerPATCH 363/567 i3c: mipi-i3c-hci: Restart DMA ring correctly after dequeue abort
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
commit b6d586431ae20d5157ee468d0ef62ad26798ef13 upstream.
The DMA dequeue path attempts to restart the ring after aborting an in-flight transfer, but the current sequence is incomplete. The controller must be brought out of the aborted state and the ring control registers must be programmed in the correct order: first clearing ABORT, then re-enabling the ring and asserting RUN_STOP to resume operation.
Add the missing controller resume step and update the ring control writes so that the ring is restarted using the proper sequence.
--- drivers/i3c/master/mipi-i3c-hci/dma.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/i3c/master/mipi-i3c-hci/dma.c +2 -0
@@ -491,7 +491,9 @@ static bool hci_dma_dequeue_xfer(struct }/* restart the ring */ +mipi_i3c_hci_resume (hci);rh_reg_write (RING_CONTROL ,RING_CTRL_ENABLE ); +rh_reg_write (RING_CONTROL ,RING_CTRL_ENABLE |RING_CTRL_RUN_STOP );return did_unqueue; }
Greg Kroah-Hartman
maintainerPATCH 364/567 i3c: mipi-i3c-hci: Add missing TID field to no-op command descriptor
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
commit ec3cfd835f7c4bbd23bc9ad909d2fdc772a578bb upstream.
The internal control command descriptor used for no-op commands includes a Transaction ID (TID) field, but the no-op command constructed in hci_dma_dequeue_xfer() omitted it. As a result, the hardware receives a no-op descriptor without the expected TID.
This bug has gone unnoticed because the TID is currently not validated in the no-op completion path, but the descriptor format requires it to be present.
Add the missing TID field when generating a no-op descriptor so that its layout matches the defined command structure.
--- drivers/i3c/master/mipi-i3c-hci/cmd.h | 1 + drivers/i3c/master/mipi-i3c-hci/dma.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/i3c/master/mipi-i3c-hci/cmd.h +1 -0
@@ -17,6 +17,7 @@#define CMD_0_TOC W0_BIT_(31)#define CMD_0_ROC W0_BIT_(30)#define CMD_0_ATTR W0_MASK(2, 0) +#define CMD_0_TID W0_MASK(6, 3)/* * Response Descriptor Structure
drivers/i3c/master/mipi-i3c-hci/dma.c +1 -1
@@ -473,7 +473,7 @@ static bool hci_dma_dequeue_xfer(structu32 *ring_data = rh->xfer + rh->xfer_struct_sz * idx;/* store no-op cmd descriptor */ - *ring_data++ =FIELD_PREP (CMD_0_ATTR ,0x7 ); + *ring_data++ =FIELD_PREP (CMD_0_ATTR ,0x7 ) |FIELD_PREP (CMD_0_TID , xfer->cmd_tid); *ring_data++ =0 ;if (hci->cmd == &mipi_i3c_hci_cmd_v2) { *ring_data++ =0 ;
Greg Kroah-Hartman
maintainerPATCH 365/567 drm/bridge: ti-sn65dsi86: Add support for DisplayPort mode with HPD
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Ripple <[email protected]>
commit 9133bc3f0564890218cbba6cc7e81ebc0841a6f1 upstream.
Add support for DisplayPort to the bridge, which entails the following:
- Get and use an interrupt for HPD;
- Properly clear all status bits in the interrupt handler;
--- drivers/gpu/drm/bridge/ti-sn65dsi86.c | 112 ++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+)
drivers/gpu/drm/bridge/ti-sn65dsi86.c +112 -0
@@ -106,10 +106,21 @@#define SN_PWM_EN_INV_REG 0xA5#define SN_PWM_INV_MASK BIT(0)#define SN_PWM_EN_MASK BIT(1) + +#define SN_IRQ_EN_REG 0xE0 +#define IRQ_EN BIT(0) + +#define SN_IRQ_EVENTS_EN_REG 0xE6 +#define HPD_INSERTION_EN BIT(1) +#define HPD_REMOVAL_EN BIT(2) +#define SN_AUX_CMD_STATUS_REG 0xF4#define AUX_IRQ_STATUS_AUX_RPLY_TOUT BIT(3)#define AUX_IRQ_STATUS_AUX_SHORT BIT(5)#define AUX_IRQ_STATUS_NAT_I2C_FAIL BIT(6) +#define SN_IRQ_STATUS_REG 0xF5 +#define HPD_REMOVAL_STATUS BIT(2) +#define HPD_INSERTION_STATUS BIT(1)#define MIN_DSI_CLK_FREQ_MHZ 40
@@ -152,7 +163,9 @@* @ln_assign: Value to program to the LN_ASSIGN register. * @ln_polrs: Value for the 4-bit LN_POLRS field of SN_ENH_FRAME_REG. * @comms_enabled: If true then communication over the aux channel is enabled. +* @hpd_enabled: If true then HPD events are enabled. * @comms_mutex: Protects modification of comms_enabled. +* @hpd_mutex: Protects modification of hpd_enabled. * * @gchip: If we expose our GPIOs, this is used. * @gchip_output: A cache of whether we've set GPIOs to output. This
@@ -190,7 +203,9 @@ struct ti_sn65dsi86 {u8 ln_assign;u8 ln_polrs;bool comms_enabled; +bool hpd_enabled;struct mutex comms_mutex; +struct mutex hpd_mutex;#if defined(CONFIG_OF_GPIO )struct gpio_chip gchip;
@@ -221,6 +236,23 @@ static const struct regmap_config ti_sn6 .max_register = 0xFF, }; +static int ti_sn65dsi86_read_u8 (struct ti_sn65dsi86 *pdata,unsigned int reg, +u8 *val) +{ +int ret; +unsigned int reg_val; + + ret =regmap_read (pdata->regmap, reg, ®_val); +if (ret) { +dev_err (pdata->dev,"fail to read raw reg %#x: %d\n" , + reg, ret); +return ret; + } + *val = (u8 )reg_val; + +return 0 ; +} +static int __maybe_unused ti_sn65dsi86_read_u16 (struct ti_sn65dsi86 *pdata,unsigned int reg,u16 *val) {
@@ -362,6 +394,7 @@ static void ti_sn65dsi86_disable_comms(sstatic int __maybe_unused ti_sn65dsi86_resume (struct device *dev) {struct ti_sn65dsi86 *pdata =dev_get_drvdata (dev); +const struct i2c_client *client =to_i2c_client (pdata->dev);int ret; ret =regulator_bulk_enable (SN_REGULATOR_SUPPLY_NUM , pdata->supplies);
@@ -396,6 +429,13 @@ static int __maybe_unused ti_sn65dsi86_rif (pdata->refclk)ti_sn65dsi86_enable_comms (pdata); +if (client->irq) { + ret =regmap_update_bits (pdata->regmap,SN_IRQ_EN_REG ,IRQ_EN , +IRQ_EN ); +if (ret) +dev_err (pdata->dev,"Failed to enable IRQ events: %d\n" , ret); + } +return ret; }
@@ -1223,6 +1263,8 @@ static void ti_sn65dsi86_debugfs_init(ststatic void ti_sn_bridge_hpd_enable (struct drm_bridge *bridge) {struct ti_sn65dsi86 *pdata =bridge_to_ti_sn65dsi86 (bridge); +const struct i2c_client *client =to_i2c_client (pdata->dev); +int ret;/* * Device needs to be powered on before reading the HPD state
@@ -1231,11 +1273,35 @@ static void ti_sn_bridge_hpd_enable(stru*/ pm_runtime_get_sync (pdata->dev); + +mutex_lock (&pdata->hpd_mutex); + pdata->hpd_enabled = true; +mutex_unlock (&pdata->hpd_mutex); + +if (client->irq) { + ret =regmap_set_bits (pdata->regmap,SN_IRQ_EVENTS_EN_REG , +HPD_REMOVAL_EN |HPD_INSERTION_EN ); +if (ret) +dev_err (pdata->dev,"Failed to enable HPD events: %d\n" , ret); + } }static void ti_sn_bridge_hpd_disable (struct drm_bridge *bridge) {struct ti_sn65dsi86 *pdata =bridge_to_ti_sn65dsi86 (bridge); +const struct i2c_client *client =to_i2c_client (pdata->dev); +int ret; + +if (client->irq) { + ret =regmap_clear_bits (pdata->regmap,SN_IRQ_EVENTS_EN_REG , +HPD_REMOVAL_EN |HPD_INSERTION_EN ); +if (ret) +dev_err (pdata->dev,"Failed to disable HPD events: %d\n" , ret); + } + +mutex_lock (&pdata->hpd_mutex); + pdata->hpd_enabled = false; +mutex_unlock (&pdata->hpd_mutex);pm_runtime_put_autosuspend (pdata->dev); }
@@ -1321,6 +1387,41 @@ static int ti_sn_bridge_parse_dsi_host(sreturn 0 ; } +static irqreturn_t ti_sn_bridge_interrupt (int irq,void *private) +{ +struct ti_sn65dsi86 *pdata = private; +struct drm_device *dev = pdata->bridge.dev; +u8 status; +int ret; +bool hpd_event; + + ret =ti_sn65dsi86_read_u8 (pdata,SN_IRQ_STATUS_REG , &status); +if (ret) { +dev_err (pdata->dev,"Failed to read IRQ status: %d\n" , ret); +return IRQ_NONE ; + } + + hpd_event = status & (HPD_REMOVAL_STATUS |HPD_INSERTION_STATUS ); + +dev_dbg (pdata->dev,"(SN_IRQ_STATUS_REG = %#x)\n" , status); +if (!status) +return IRQ_NONE ; + + ret =regmap_write (pdata->regmap,SN_IRQ_STATUS_REG , status); +if (ret) { +dev_err (pdata->dev,"Failed to clear IRQ status: %d\n" , ret); +return IRQ_NONE ; + } + +/* Only send the HPD event if we are bound with a device. */ +mutex_lock (&pdata->hpd_mutex); +if (pdata->hpd_enabled && hpd_event) +drm_kms_helper_hotplug_event (dev); +mutex_unlock (&pdata->hpd_mutex); + +return IRQ_HANDLED ; +} +static int ti_sn_bridge_probe (struct auxiliary_device *adev,const struct auxiliary_device_id *id) {
@@ -1951,6 +2052,7 @@ static int ti_sn65dsi86_probe(struct i2cdev_set_drvdata (dev, pdata); pdata->dev = dev; +mutex_init (&pdata->hpd_mutex);mutex_init (&pdata->comms_mutex); pdata->regmap = devm_regmap_init_i2c(client,
@@ -1981,6 +2083,16 @@ static int ti_sn65dsi86_probe(struct i2cif (ret)return ret; +if (client->irq) { + ret =devm_request_threaded_irq (pdata->dev, client->irq,NULL , + ti_sn_bridge_interrupt, +IRQF_ONESHOT , +dev_name (pdata->dev), pdata); + +if (ret) +return dev_err_probe (dev, ret,"failed to request interrupt\n" ); + } +/* * Break ourselves up into a collection of aux devices. The only real * motiviation here is to solve the chicken-and-egg problem of probe
Greg Kroah-Hartman
maintainerPATCH 366/567 gve: defer interrupt enabling until NAPI registration
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ankit Garg <[email protected]>
[ Upstream commit 3d970eda003441f66551a91fda16478ac0711617 ]
Currently, interrupts are automatically enabled immediately upon request. This allows interrupt to fire before the associated NAPI context is fully initialized and cause failures like below:
[ 0.946369] Call Trace: [ 0.946369] <IRQ> [ 0.946369] __napi_poll+0x2a/0x1e0 [ 0.946369] net_rx_action+0x2f9/0x3f0 [ 0.946369] handle_softirqs+0xd6/0x2c0 [ 0.946369] ? handle_edge_irq+0xc1/0x1b0 [ 0.946369] __irq_exit_rcu+0xc3/0xe0 [ 0.946369] common_interrupt+0x81/0xa0 [ 0.946369] </IRQ> [ 0.946369] <TASK> [ 0.946369] asm_common_interrupt+0x22/0x40 [ 0.946369] RIP: 0010:pv_native_safe_halt+0xb/0x10
Use the IRQF_NO_AUTOEN flag when requesting interrupts to prevent auto enablement and explicitly enable the interrupt in NAPI initialization path (and disable it during NAPI teardown).
This ensures that interrupt lifecycle is strictly coupled with readiness of NAPI context.
[ modified to re-introduce the irq member to struct gve_notify_block,
which was introuduced in commit 9a5e0776d11f ("gve: Avoid rescheduling napi if on wrong cpu"). ]
--- drivers/net/ethernet/google/gve/gve.h | 1 + drivers/net/ethernet/google/gve/gve_main.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/google/gve/gve.h +1 -0
@@ -585,6 +585,7 @@ struct gve_notify_block {struct gve_priv *priv;struct gve_tx_ring *tx;/* tx rings on this block */ struct gve_rx_ring *rx;/* rx rings on this block */ +u32 irq; };/* Tracks allowed and current queue settings */
drivers/net/ethernet/google/gve/gve_main.c +4 -1
@@ -407,9 +407,10 @@ static int gve_alloc_notify_blocks(strucsnprintf (block->name,sizeof (block->name),"gve-ntfy-blk%d@pci:%s" , i,pci_name (priv->pdev)); block->priv = priv; + block->irq = priv->msix_vectors[msix_idx].vector; err =request_irq (priv->msix_vectors[msix_idx].vector,gve_is_gqi (priv) ? gve_intr : gve_intr_dqo, -0 , block->name, block); +IRQF_NO_AUTOEN , block->name, block);if (err) {dev_err (&priv->pdev->dev,"Failed to receive msix vector %d\n" , i);
@@ -575,6 +576,7 @@ static void gve_add_napi(struct gve_privstruct gve_notify_block *block = &priv->ntfy_blocks[ntfy_idx];netif_napi_add (priv->dev, &block->napi, gve_poll); +enable_irq (block->irq); }static void gve_remove_napi (struct gve_priv *priv,int ntfy_idx)
@@ -582,6 +584,7 @@ static void gve_remove_napi(struct gve_pstruct gve_notify_block *block = &priv->ntfy_blocks[ntfy_idx];netif_napi_del (&block->napi); +disable_irq (block->irq); }static int gve_register_xdp_qpls (struct gve_priv *priv)
Greg Kroah-Hartman
maintainerPATCH 367/567 ksmbd: call ksmbd_vfs_kern_path_end_removing() on some error paths
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fedor Pchelkin <[email protected]>
[ Upstream commit a09dc10d1353f0e92c21eae2a79af1c2b1ddcde8 ]
There are two places where ksmbd_vfs_kern_path_end_removing() needs to be called in order to balance what the corresponding successful call to ksmbd_vfs_kern_path_start_removing() has done, i.e. drop inode locks and put the taken references. Otherwise there might be potential deadlocks and unbalanced locks which are caught like:
BUG: workqueue leaked lock or atomic: kworker/5:21/0x00000000/7596
last function: handle_ksmbd_work
2 locks held by kworker/5:21/7596:
#0: ffff8881051ae448 (sb_writers#3){.+.+}-{0:0}, at: ksmbd_vfs_kern_path_locked+0x142/0x660
#1: ffff888130e966c0 (&type->i_mutex_dir_key#3/1){+.+.}-{4:4}, at: ksmbd_vfs_kern_path_locked+0x17d/0x660
CPU: 5 PID: 7596 Comm: kworker/5:21 Not tainted 6.1.162-00456-gc29b353f383b #138
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-debian-1.17.0-1 04/01/2014
Workqueue: ksmbd-io handle_ksmbd_work
Call Trace:
<TASK>
dump_stack_lvl+0x44/0x5b
process_one_work.cold+0x57/0x5c
worker_thread+0x82/0x600
kthread+0x153/0x190
ret_from_fork+0x22/0x30
</TASK>Found by Linux Verification Center (linuxtesting.org).
--- fs/smb/server/smb2pdu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/server/smb2pdu.c +2 -2
@@ -6067,14 +6067,14 @@ static int smb2_create_link(struct ksmbd rc = -EINVAL ;ksmbd_debug (SMB ,"cannot delete %s\n" , link_name); - goto out; } }else { rc = -EEXIST ;ksmbd_debug (SMB ,"link already exists\n" ); - goto out; }ksmbd_vfs_kern_path_unlock (&parent_path, &path); +if (rc) + goto out; } rc =ksmbd_vfs_link (work, target_name, link_name);if (rc)
Greg Kroah-Hartman
maintainerPATCH 368/567 wifi: libertas: fix use-after-free in lbs_free_adapter()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Hodges <[email protected]>
[ Upstream commit 03cc8f90d0537fcd4985c3319b4fafbf2e3fb1f0 ]
The lbs_free_adapter() function uses timer_delete() (non-synchronous) for both command_timer and tx_lockup_timer before the structure is freed. This is incorrect because timer_delete() does not wait for any running timer callback to complete.
If a timer callback is executing when lbs_free_adapter() is called, the callback will access freed memory since lbs_cfg_free() frees the containing structure immediately after lbs_free_adapter() returns.
Both timer callbacks (lbs_cmd_timeout_handler and lbs_tx_lockup_handler) access priv->driver_lock, priv->cur_cmd, priv->dev, and other fields, which would all be use-after-free violations.
Use timer_delete_sync() instead to ensure any running timer callback has completed before returning.
This bug was introduced in commit 8f641d93c38a ("libertas: detect TX lockups and reset hardware") where del_timer() was used instead of del_timer_sync() in the cleanup path. The command_timer has had the same issue since the driver was first written.
--- drivers/net/wireless/marvell/libertas/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/marvell/libertas/main.c +2 -2
@@ -881,8 +881,8 @@ static void lbs_free_adapter(struct lbs_ {lbs_free_cmd_buffer (priv);kfifo_free (&priv->event_fifo); -del_timer (&priv->command_timer); -del_timer (&priv->tx_lockup_timer); +timer_delete_sync (&priv->command_timer); +timer_delete_sync (&priv->tx_lockup_timer);del_timer (&priv->auto_deepsleep_timer); }
Greg Kroah-Hartman
maintainerPATCH 369/567 platform/x86: hp-bioscfg: Support allocations of larger data
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
[ Upstream commit 916727cfdb72cd01fef3fa6746e648f8cb70e713 ]
Some systems have much larger amounts of enumeration attributes than have been previously encountered. This can lead to page allocation failures when using kcalloc(). Switch over to using kvcalloc() to allow larger allocations.
--- drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c +6 -3
@@ -96,8 +96,11 @@ int hp_alloc_enumeration_data(void) bioscfg_drv.enumeration_instances_count =hp_get_instance_count (HP_WMI_BIOS_ENUMERATION_GUID ); - bioscfg_drv.enumeration_data =kcalloc (bioscfg_drv.enumeration_instances_count, -sizeof (*bioscfg_drv.enumeration_data),GFP_KERNEL ); +if (!bioscfg_drv.enumeration_instances_count) +return -EINVAL ; + bioscfg_drv.enumeration_data =kvcalloc (bioscfg_drv.enumeration_instances_count, +sizeof (*bioscfg_drv.enumeration_data),GFP_KERNEL ); +if (!bioscfg_drv.enumeration_data) { bioscfg_drv.enumeration_instances_count =0 ;return -ENOMEM ;
@@ -452,6 +455,6 @@ void hp_exit_enumeration_attributes(void } bioscfg_drv.enumeration_instances_count =0 ; -kfree (bioscfg_drv.enumeration_data); +kvfree (bioscfg_drv.enumeration_data); bioscfg_drv.enumeration_data =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 370/567 x86/sev: Allow IBPB-on-Entry feature for SNP guests
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kim Phillips <[email protected]>
[ Upstream commit 9073428bb204d921ae15326bb7d4558d9d269aab ]
The SEV-SNP IBPB-on-Entry feature does not require a guest-side implementation. It was added in Zen5 h/w, after the first SNP Zen implementation, and thus was not accounted for when the initial set of SNP features were added to the kernel.
In its abundant precaution, commit
8c29f0165405 ("x86/sev: Add SEV-SNP guest feature negotiation support")
included SEV_STATUS' IBPB-on-Entry bit as a reserved bit, thereby masking guests from using the feature.
Allow guests to make use of IBPB-on-Entry when supported by the hypervisor, as the bit is now architecturally defined and safe to expose.
--- arch/x86/boot/compressed/sev.c | 1 + arch/x86/include/asm/msr-index.h | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-)
arch/x86/boot/compressed/sev.c +1 -0
@@ -341,6 +341,7 @@ static void enforce_vmpl0(void)MSR_AMD64_SNP_VMSA_REG_PROTECTION | \MSR_AMD64_SNP_RESERVED_BIT13 | \MSR_AMD64_SNP_RESERVED_BIT15 | \ +MSR_AMD64_SNP_RESERVED_BITS18_22 | \ MSR_AMD64_SNP_RESERVED_MASK)/*
arch/x86/include/asm/msr-index.h +4 -1
@@ -632,11 +632,14 @@#define MSR_AMD64_SNP_IBS_VIRT BIT_ULL(14)#define MSR_AMD64_SNP_VMSA_REG_PROTECTION BIT_ULL(16)#define MSR_AMD64_SNP_SMT_PROTECTION BIT_ULL(17) +#define MSR_AMD64_SNP_IBPB_ON_ENTRY_BIT 23 +#define MSR_AMD64_SNP_IBPB_ON_ENTRY BIT_ULL(MSR_AMD64_SNP_IBPB_ON_ENTRY_BIT)/* SNP feature bits reserved for future use. */ #define MSR_AMD64_SNP_RESERVED_BIT13 BIT_ULL(13)#define MSR_AMD64_SNP_RESERVED_BIT15 BIT_ULL(15) -#define MSR_AMD64_SNP_RESERVED_MASK GENMASK_ULL(63, 18) +#define MSR_AMD64_SNP_RESERVED_BITS18_22 GENMASK_ULL(22, 18) +#define MSR_AMD64_SNP_RESERVED_MASK GENMASK_ULL(63, 24)#define MSR_AMD64_VIRT_SPEC_CTRL 0xc001011f
Greg Kroah-Hartman
maintainerPATCH 371/567 gve: fix incorrect buffer cleanup in gve_tx_clean_pending_packets for QPL
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ankit Garg <[email protected]>
[ Upstream commit fb868db5f4bccd7a78219313ab2917429f715cea ]
In DQ-QPL mode, gve_tx_clean_pending_packets() incorrectly uses the RDA buffer cleanup path. It iterates num_bufs times and attempts to unmap entries in the dma array.
This leads to two issues:
1. The dma array shares storage with tx_qpl_buf_ids (union). Interpreting buffer IDs as DMA addresses results in attempting to unmap incorrect memory locations.
2. num_bufs in QPL mode (counting 2K chunks) can significantly exceed the size of the dma array, causing out-of-bounds access warnings
(trace below is how we noticed this issue).
UBSAN: array-index-out-of-bounds in drivers/net/ethernet/drivers/net/ethernet/google/gve/gve_tx_dqo.c:178:5 index 18 is out of range for type 'dma_addr_t[18]' (aka 'unsigned long long[18]') Workqueue: gve gve_service_task [gve] Call Trace: <TASK> dump_stack_lvl+0x33/0xa0 __ubsan_handle_out_of_bounds+0xdc/0x110 gve_tx_stop_ring_dqo+0x182/0x200 [gve] gve_close+0x1be/0x450 [gve] gve_reset+0x99/0x120 [gve] gve_service_task+0x61/0x100 [gve] process_scheduled_works+0x1e9/0x380
Fix this by properly checking for QPL mode and delegating to gve_free_tx_qpl_bufs() to reclaim the buffers.
--- drivers/net/ethernet/google/gve/gve_tx_dqo.c | 52 +++++++++++---------------- 1 file changed, 23 insertions(+), 29 deletions(-)
drivers/net/ethernet/google/gve/gve_tx_dqo.c +23 -29
@@ -157,6 +157,24 @@ gve_free_pending_packet(struct gve_tx_ri } } +static void gve_unmap_packet (struct device *dev, +struct gve_tx_pending_packet_dqo *pkt) +{ +int i; + +if (!pkt->num_bufs) +return ; + +/* SKB linear portion is guaranteed to be mapped */ +dma_unmap_single (dev,dma_unmap_addr (pkt, dma[0 ]), +dma_unmap_len (pkt, len[0 ]),DMA_TO_DEVICE ); +for (i =1 ; i < pkt->num_bufs; i++) { +dma_unmap_page (dev,dma_unmap_addr (pkt, dma[i]), +dma_unmap_len (pkt, len[i]),DMA_TO_DEVICE ); + } + pkt->num_bufs =0 ; +} +/* gve_tx_free_desc - Cleans up all pending tx requests and buffers. */ static void gve_tx_clean_pending_packets (struct gve_tx_ring *tx)
@@ -166,21 +184,12 @@ static void gve_tx_clean_pending_packetsfor (i =0 ; i < tx->dqo.num_pending_packets; i++) {struct gve_tx_pending_packet_dqo *cur_state = &tx->dqo.pending_packets[i]; -int j; -for (j =0 ; j < cur_state->num_bufs; j++) { -if (j ==0 ) { -dma_unmap_single (tx->dev, -dma_unmap_addr (cur_state, dma[j]), -dma_unmap_len (cur_state, len[j]), -DMA_TO_DEVICE ); - }else { -dma_unmap_page (tx->dev, -dma_unmap_addr (cur_state, dma[j]), -dma_unmap_len (cur_state, len[j]), -DMA_TO_DEVICE ); - } - } +if (tx->dqo.qpl) +gve_free_tx_qpl_bufs (tx, cur_state); +else +gve_unmap_packet (tx->dev, cur_state); +if (cur_state->skb) {dev_consume_skb_any (cur_state->skb); cur_state->skb =NULL ;
@@ -992,21 +1001,6 @@ static void remove_from_list(struct gve_ } } -static void gve_unmap_packet (struct device *dev, -struct gve_tx_pending_packet_dqo *pkt) -{ -int i; - -/* SKB linear portion is guaranteed to be mapped */ -dma_unmap_single (dev,dma_unmap_addr (pkt, dma[0 ]), -dma_unmap_len (pkt, len[0 ]),DMA_TO_DEVICE ); -for (i =1 ; i < pkt->num_bufs; i++) { -dma_unmap_page (dev,dma_unmap_addr (pkt, dma[i]), -dma_unmap_len (pkt, len[i]),DMA_TO_DEVICE ); - } - pkt->num_bufs =0 ; -} -/* Completion types and expected behavior: * No Miss compl + Packet compl = Packet completed normally. * Miss compl + Re-inject compl = Packet completed normally.
Greg Kroah-Hartman
maintainerPATCH 372/567 net: phy: register phy led_triggers during probe to avoid AB-BA deadlock
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Lunn <[email protected]>
[ Upstream commit c8dbdc6e380e7e96a51706db3e4b7870d8a9402d ]
There is an AB-BA deadlock when both LEDS_TRIGGER_NETDEV and LED_TRIGGER_PHY are enabled:
[ 1362.049207] [<8054e4b8>] led_trigger_register+0x5c/0x1fc <-- Trying to get lock "triggers_list_lock" via down_write(&triggers_list_lock); [ 1362.054536] [<80662830>] phy_led_triggers_register+0xd0/0x234 [ 1362.060329] [<8065e200>] phy_attach_direct+0x33c/0x40c [ 1362.065489] [<80651fc4>] phylink_fwnode_phy_connect+0x15c/0x23c [ 1362.071480] [<8066ee18>] mtk_open+0x7c/0xba0 [ 1362.075849] [<806d714c>] __dev_open+0x280/0x2b0 [ 1362.080384] [<806d7668>] __dev_change_flags+0x244/0x24c [ 1362.085598] [<806d7698>] dev_change_flags+0x28/0x78 [ 1362.090528] [<807150e4>] dev_ioctl+0x4c0/0x654 <-- Hold lock "rtnl_mutex" by calling rtnl_lock(); [ 1362.094985] [<80694360>] sock_ioctl+0x2f4/0x4e0 [ 1362.099567] [<802e9c4c>] sys_ioctl+0x32c/0xd8c [ 1362.104022] [<80014504>] syscall_common+0x34/0x58
Here LED_TRIGGER_PHY is registering LED triggers during phy_attach while holding RTNL and then taking triggers_list_lock.
[ 1362.191101] [<806c2640>] register_netdevice_notifier+0x60/0x168 <-- Trying to get lock "rtnl_mutex" via rtnl_lock(); [ 1362.197073] [<805504ac>] netdev_trig_activate+0x194/0x1e4 [ 1362.202490] [<8054e28c>] led_trigger_set+0x1d4/0x360 <-- Hold lock "triggers_list_lock" by down_read(&triggers_list_lock); [ 1362.207511] [<8054eb38>] led_trigger_write+0xd8/0x14c [ 1362.212566] [<80381d98>] sysfs_kf_bin_write+0x80/0xbc [ 1362.217688] [<8037fcd8>] kernfs_fop_write_iter+0x17c/0x28c [ 1362.223174] [<802cbd70>] vfs_write+0x21c/0x3c4 [ 1362.227712] [<802cc0c4>] ksys_write+0x78/0x12c [ 1362.232164] [<80014504>] syscall_common+0x34/0x58
Here LEDS_TRIGGER_NETDEV is being enabled on an LED. It first takes triggers_list_lock and then RTNL. A classical AB-BA deadlock.
phy_led_triggers_registers() does not require the RTNL, it does not make any calls into the network stack which require protection. There is also no requirement the PHY has been attached to a MAC, the triggers only make use of phydev state. This allows the call to phy_led_triggers_registers() to be placed elsewhere. PHY probe() and release() don't hold RTNL, so solving the AB-BA deadlock.
--- drivers/net/phy/phy_device.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
drivers/net/phy/phy_device.c +17 -8
@@ -1582,8 +1582,6 @@ int phy_attach_direct(struct net_device goto error;phy_resume (phydev); -if (!phydev->is_on_sfp_module) -phy_led_triggers_register (phydev);/** * If the external phy used by current mac interface is managed by
@@ -1856,9 +1854,6 @@ void phy_detach(struct phy_device *phyde phydev->phy_link_change =NULL ; phydev->phylink =NULL ; -if (!phydev->is_on_sfp_module) -phy_led_triggers_unregister (phydev); -if (phydev->mdio.dev.driver)module_put (phydev->mdio.dev.driver->owner);
@@ -3402,17 +3397,28 @@ static int phy_probe(struct device *dev)/* Set the state to READY by default */ phydev->state =PHY_READY ; +/* Register the PHY LED triggers */ +if (!phydev->is_on_sfp_module) +phy_led_triggers_register (phydev); +/* Get the LEDs from the device tree, and instantiate standard * LEDs for them. */ if (IS_ENABLED (CONFIG_PHYLIB_LEDS ) && !phy_driver_is_genphy (phydev) && - !phy_driver_is_genphy_10g (phydev)) + !phy_driver_is_genphy_10g (phydev)) { err =of_phy_leds (phydev); +if (err) + goto out; + } + +return 0 ; out: +if (!phydev->is_on_sfp_module) +phy_led_triggers_unregister (phydev); +/* Re-assert the reset signal on error */ -if (err) -phy_device_reset (phydev,1 ); +phy_device_reset (phydev,1 );return err; }
@@ -3427,6 +3433,9 @@ static int phy_remove(struct device *dev !phy_driver_is_genphy_10g(phydev))phy_leds_unregister (phydev); +if (!phydev->is_on_sfp_module) +phy_led_triggers_unregister (phydev); + phydev->state =PHY_DOWN ;sfp_bus_del_upstream (phydev->sfp_bus);
Greg Kroah-Hartman
maintainerPATCH 373/567 drm/amd/display: Use GFP_ATOMIC in dc_create_stream_for_sink
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Natalie Vock <[email protected]>
[ Upstream commit 28dfe4317541e57fe52f9a290394cd29c348228b ]
This can be called while preemption is disabled, for example by dcn32_internal_validate_bw which is called with the FPU active.
Fixes "BUG: scheduling while atomic" messages I encounter on my Navi31 machine.
--- drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_stream.c +1 -1
@@ -164,7 +164,7 @@ struct dc_stream_state *dc_create_streamif (sink ==NULL )return NULL ; - stream =kzalloc (sizeof (struct dc_stream_state ),GFP_KERNEL ); + stream =kzalloc (sizeof (struct dc_stream_state ),GFP_ATOMIC );if (stream ==NULL ) goto alloc_fail;
Greg Kroah-Hartman
maintainerPATCH 374/567 mptcp: pm: avoid sending RM_ADDR over same subflow
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Matthieu Baerts (NGI0)" <[email protected]>
[ Upstream commit fb8d0bccb221080630efcd9660c9f9349e53cc9e ]
RM_ADDR are sent over an active subflow, the first one in the subflows list. There is then a high chance the initial subflow is picked. With the in-kernel PM, when an endpoint is removed, a RM_ADDR is sent, then linked subflows are closed. This is done for each active MPTCP connection.
MPTCP endpoints are likely removed because the attached network is no longer available or usable. In this case, it is better to avoid sending this RM_ADDR over the subflow that is going to be removed, but prefer sending it over another active and non stale subflow, if any.
This modification avoids situations where the other end is not notified when a subflow is no longer usable: typically when the endpoint linked to the initial subflow is removed, especially on the server side.
--- net/mptcp/pm.c | 2 +- net/mptcp/pm_netlink.c | 43 ++++++++++++++++++++++++++++++++++++++----- net/mptcp/protocol.h | 2 ++ 3 files changed, 41 insertions(+), 6 deletions(-)
net/mptcp/pm.c +1 -1
@@ -57,7 +57,7 @@ int mptcp_pm_remove_addr(struct mptcp_so msk->pm.rm_list_tx = *rm_list; rm_addr |=BIT (MPTCP_RM_ADDR_SIGNAL );WRITE_ONCE (msk->pm.addr_signal, rm_addr); -mptcp_pm_nl_addr_send_ack (msk); +mptcp_pm_nl_addr_send_ack_avoid_list (msk, rm_list);return 0 ; }
net/mptcp/pm_netlink.c +38 -5
58 lines not on this page · raw message
net/mptcp/protocol.h +2 -0
@@ -932,6 +932,8 @@ void mptcp_pm_add_addr_send_ack(struct mbool mptcp_pm_nl_is_init_remote_addr (struct mptcp_sock *msk,const struct mptcp_addr_info *remote);void mptcp_pm_nl_addr_send_ack (struct mptcp_sock *msk); +void mptcp_pm_nl_addr_send_ack_avoid_list (struct mptcp_sock *msk, +const struct mptcp_rm_list *rm_list);void mptcp_pm_rm_addr_received (struct mptcp_sock *msk,const struct mptcp_rm_list *rm_list);void mptcp_pm_mp_prio_received (struct sock *sk,u8 bkup);
Greg Kroah-Hartman
maintainerPATCH 375/567 mptcp: pm: in-kernel: always mark signal+subflow endp as used
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Matthieu Baerts (NGI0)" <[email protected]>
[ Upstream commit 579a752464a64cb5f9139102f0e6b90a1f595ceb ]
Syzkaller managed to find a combination of actions that was generating this warning:
msk->pm.local_addr_used == 0
WARNING: net/mptcp/pm_kernel.c:1071 at __mark_subflow_endp_available net/mptcp/pm_kernel.c:1071 [inline], CPU#1: syz.2.17/961 WARNING: net/mptcp/pm_kernel.c:1071 at mptcp_nl_remove_subflow_and_signal_addr net/mptcp/pm_kernel.c:1103 [inline], CPU#1: syz.2.17/961 WARNING: net/mptcp/pm_kernel.c:1071 at mptcp_pm_nl_del_addr_doit+0x81d/0x8f0 net/mptcp/pm_kernel.c:1210, CPU#1: syz.2.17/961 Modules linked in: CPU: 1 UID: 0 PID: 961 Comm: syz.2.17 Not tainted 6.19.0-08368-gfafda3b4b06b #22 PREEMPT(full) Hardware name: QEMU Ubuntu 25.10 PC v2 (i440FX + PIIX, + 10.1 machine, 1996), BIOS 1.17.0-debian-1.17.0-1build1 04/01/2014 RIP: 0010:__mark_subflow_endp_available net/mptcp/pm_kernel.c:1071 [inline] RIP: 0010:mptcp_nl_remove_subflow_and_signal_addr net/mptcp/pm_kernel.c:1103 [inline] RIP: 0010:mptcp_pm_nl_del_addr_doit+0x81d/0x8f0 net/mptcp/pm_kernel.c:1210 Code: 89 c5 e8 46 30 6f fe e9 21 fd ff ff 49 83 ed 80 e8 38 30 6f fe 4c 89 ef be 03 00 00 00 e8 db 49 df fe eb ac e8 24 30 6f fe 90 <0f> 0b 90 e9 1d ff ff ff e8 16 30 6f fe eb 05 e8 0f 30 6f fe e8 9a RSP: 0018:ffffc90001663880 EFLAGS: 00010293 RAX: ffffffff82de1a6c RBX: 0000000000000000 RCX: ffff88800722b500 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: ffff8880158b22d0 R08: 0000000000010425 R09: ffffffffffffffff R10: ffffffff82de18ba R11: 0000000000000000 R12: ffff88800641a640 R13: ffff8880158b1880 R14: ffff88801ec3c900 R15: ffff88800641a650 FS: 00005555722c3500(0000) GS:ffff8880f909d000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f66346e0f60 CR3: 000000001607c000 CR4: 0000000000350ef0 Call Trace: <TASK> genl_family_rcv_msg_doit+0x117/0x180 net/netlink/genetlink.c:1115 genl_family_rcv_msg net/netlink/genetlink.c:1195 [inline] genl_rcv_msg+0x3a8/0x3f0 net/netlink/genetlink.c:1210 netlink_rcv_skb+0x16d/0x240 net/netlink/af_netlink.c:2550 genl_rcv+0x28/0x40 net/netlink/genetlink.c:1219 netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline] netlink_unicast+0x3e9/0x4c0 net/netlink/af_netlink.c:1344 netlink_sendmsg+0x4aa/0x5b0 net/netlink/af_netlink.c:1894 sock_sendmsg_nosec net/socket.c:727 [inline] __sock_sendmsg+0xc9/0xf0 net/socket.c:742 ____sys_sendmsg+0x272/0x3b0 net/socket.c:2592 ___sys_sendmsg+0x2de/0x320 net/socket.c:2646 __sys_sendmsg net/socket.c:2678 [inline] __do_sys_sendmsg net/socket.c:2683 [inline] __se_sys_sendmsg net/socket.c:2681 [inline] __x64_sys_sendmsg+0x110/0x1a0 net/socket.c:2681 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x143/0x440 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f66346f826d Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007ffc83d8bdc8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007f6634985fa0 RCX: 00007f66346f826d RDX: 00000000040000b0 RSI: 0000200000000740 RDI: 0000000000000007 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007f6634985fa8 R13: 00007f6634985fac R14: 0000000000000000 R15: 0000000000001770 </TASK>
The actions that caused that seem to be:
- Set the MPTCP subflows limit to 0
- Create an MPTCP endpoint with both the 'signal' and 'subflow' flags
- Create a new MPTCP connection from a different address: an ADD_ADDR linked to the MPTCP endpoint will be sent ('signal' flag), but no subflows is initiated ('subflow' flag)
- Remove the MPTCP endpoint
In this case, msk->pm.local_addr_used has been kept to 0 -- because no subflows have been created -- but the corresponding bit in msk->pm.id_avail_bitmap has been cleared when the ADD_ADDR has been sent. This later causes a splat when removing the MPTCP endpoint because msk->pm.local_addr_used has been kept to 0.
Now, if an endpoint has both the signal and subflow flags, but it is not possible to create subflows because of the limits or the c-flag case, then the local endpoint counter is still incremented: the endpoint is used at the end. This avoids issues later when removing the endpoint and calling __mark_subflow_endp_available(), which expects msk->pm.local_addr_used to have been previously incremented if the endpoint was marked as used according to msk->pm.id_avail_bitmap.
Note that signal_and_subflow variable is reset to false when the limits and the c-flag case allows subflows creation. Also, local_addr_used is only incremented for non ID0 subflows.
--- net/mptcp/pm_netlink.c | 9 +++++++++ 1 file changed, 9 insertions(+)
net/mptcp/pm_netlink.c +9 -0
@@ -662,6 +662,15 @@ subflow: } exit: +/* If an endpoint has both the signal and subflow flags, but it is not +* possible to create subflows -- the 'while' loop body above never +* executed -- then still mark the endp as used, which is somehow the +* case. This avoids issues later when removing the endpoint and calling +* __mark_subflow_endp_available(), which expects the increment here. +*/ +if (signal_and_subflow && local.addr.id != msk->mpc_endpoint_id) + msk->pm.local_addr_used++; +mptcp_pm_nl_check_work_pending (msk); }
Greg Kroah-Hartman
maintainerPATCH 376/567 selftests: mptcp: add a check for add_addr_accepted
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gang Yan <[email protected]>
[ Upstream commit 0eee0fdf9b7b0baf698f9b426384aa9714d76a51 ]
The previous patch fixed an issue with the 'add_addr_accepted' counter. This was not spot by the test suite.
Check this counter and 'add_addr_signal' in MPTCP Join 'delete re-add signal' test. This should help spotting similar regressions later on. These counters are crucial for ensuring the MPTCP path manager correctly handles the subflow creation via 'ADD_ADDR'.
Stable-dep-of: 560edd99b5f5 ("selftests: mptcp: join: check RM_ADDR not sent over same subflow")
--- tools/testing/selftests/net/mptcp/mptcp_join.sh | 7 +++++++ 1 file changed, 7 insertions(+)
tools/testing/selftests/net/mptcp/mptcp_join.sh +7 -0
@@ -3934,38 +3934,45 @@ endpoint_tests() $ns1 10.0.2.1 id 1 flags signal chk_subflow_nr "before delete" 2 chk_mptcp_info subflows 1 subflows 1 + chk_mptcp_info add_addr_signal 2 add_addr_accepted 1 pm_nl_del_endpoint $ns1 1 10.0.2.1 pm_nl_del_endpoint $ns1 2 224.0.0.1 sleep 0.5 chk_subflow_nr "after delete" 1 chk_mptcp_info subflows 0 subflows 0 + chk_mptcp_info add_addr_signal 0 add_addr_accepted 0 pm_nl_add_endpoint $ns1 10.0.2.1 id 1 flags signal pm_nl_add_endpoint $ns1 10.0.3.1 id 2 flags signal wait_mpj $ns2 chk_subflow_nr "after re-add" 3 chk_mptcp_info subflows 2 subflows 2 + chk_mptcp_info add_addr_signal 2 add_addr_accepted 2 pm_nl_del_endpoint $ns1 42 10.0.1.1 sleep 0.5 chk_subflow_nr "after delete ID 0" 2 chk_mptcp_info subflows 2 subflows 2 + chk_mptcp_info add_addr_signal 2 add_addr_accepted 2 pm_nl_add_endpoint $ns1 10.0.1.1 id 99 flags signal wait_mpj $ns2 chk_subflow_nr "after re-add ID 0" 3 chk_mptcp_info subflows 3 subflows 3 + chk_mptcp_info add_addr_signal 3 add_addr_accepted 2 pm_nl_del_endpoint $ns1 99 10.0.1.1 sleep 0.5 chk_subflow_nr "after re-delete ID 0" 2 chk_mptcp_info subflows 2 subflows 2 + chk_mptcp_info add_addr_signal 2 add_addr_accepted 2 pm_nl_add_endpoint $ns1 10.0.1.1 id 88 flags signal wait_mpj $ns2 chk_subflow_nr "after re-re-add ID 0" 3 chk_mptcp_info subflows 3 subflows 3 + chk_mptcp_info add_addr_signal 3 add_addr_accepted 2 mptcp_lib_kill_group_wait $tests_pid kill_events_pids
Greg Kroah-Hartman
maintainerPATCH 377/567 selftests: mptcp: join: check RM_ADDR not sent over same subflow
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Matthieu Baerts (NGI0)" <[email protected]>
[ Upstream commit 560edd99b5f58b2d4bbe3c8e51e1eed68d887b0e ]
This validates the previous commit: RM_ADDR were sent over the first found active subflow which could be the same as the one being removed. It is more likely to loose this notification.
For this check, RM_ADDR are explicitly dropped when trying to send them over the initial subflow, when removing the endpoint attached to it. If it is dropped, the test will complain because some RM_ADDR have not been received.
Note that only the RM_ADDR are dropped, to allow the linked subflow to be quickly and cleanly closed. To only drop those RM_ADDR, a cBPF byte code is used. If the IPTables commands fail, that's OK, the tests will continue to pass, but not validate this part. This can be ignored:
another subtest fully depends on such command, and will be marked as skipped.
The 'Fixes' tag here below is the same as the one from the previous
commit: this patch here is not fixing anything wrong in the selftests, but it validates the previous fix for an issue introduced by this commit ID.
--- tools/testing/selftests/net/mptcp/mptcp_join.sh | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
tools/testing/selftests/net/mptcp/mptcp_join.sh +36 -0
@@ -81,6 +81,24 @@ CBPF_MPTCP_SUBOPTION_ADD_ADDR="14, 6 0 0 65535, 6 0 0 0" +# IPv4: TCP hdr of 48B, a first suboption of 12B (DACK8), the RM_ADDR suboption +# generated using "nfbpf_compile '(ip[32] & 0xf0) == 0xc0 && ip[53] == 0x0c && +# (ip[66] & 0xf0) == 0x40'" +CBPF_MPTCP_SUBOPTION_RM_ADDR="13, + 48 0 0 0, + 84 0 0 240, + 21 0 9 64, + 48 0 0 32, + 84 0 0 240, + 21 0 6 192, + 48 0 0 53, + 21 0 4 12, + 48 0 0 66, + 84 0 0 240, + 21 0 1 64, + 6 0 0 65535, + 6 0 0 0" + init_partial() { capout=$(mktemp)
@@ -3880,6 +3898,14 @@ endpoint_tests() chk_subflow_nr "after no reject" 3 chk_mptcp_info subflows 2 subflows 2 + # To make sure RM_ADDR are sent over a different subflow, but + # allow the rest to quickly and cleanly close the subflow + local ipt=1 + ip netns exec "${ns2}" ${iptables} -I OUTPUT -s "10.0.1.2" \ + -p tcp -m tcp --tcp-option 30 \ + -m bpf --bytecode \ + "$CBPF_MPTCP_SUBOPTION_RM_ADDR" \ + -j DROP || ipt=0 local i for i in $(seq 3); do pm_nl_del_endpoint $ns2 1 10.0.1.2
@@ -3892,6 +3918,7 @@ endpoint_tests() chk_subflow_nr "after re-add id 0 ($i)" 3 chk_mptcp_info subflows 3 subflows 3 done + [ ${ipt} = 1 ] && ip netns exec "${ns2}" ${iptables} -D OUTPUT 1 mptcp_lib_kill_group_wait $tests_pid
@@ -3950,11 +3977,20 @@ endpoint_tests() chk_mptcp_info subflows 2 subflows 2 chk_mptcp_info add_addr_signal 2 add_addr_accepted 2 + # To make sure RM_ADDR are sent over a different subflow, but + # allow the rest to quickly and cleanly close the subflow + local ipt=1 + ip netns exec "${ns1}" ${iptables} -I OUTPUT -s "10.0.1.1" \ + -p tcp -m tcp --tcp-option 30 \ + -m bpf --bytecode \ + "$CBPF_MPTCP_SUBOPTION_RM_ADDR" \ + -j DROP || ipt=0 pm_nl_del_endpoint $ns1 42 10.0.1.1 sleep 0.5 chk_subflow_nr "after delete ID 0" 2 chk_mptcp_info subflows 2 subflows 2 chk_mptcp_info add_addr_signal 2 add_addr_accepted 2 + [ ${ipt} = 1 ] && ip netns exec "${ns1}" ${iptables} -D OUTPUT 1 pm_nl_add_endpoint $ns1 10.0.1.1 id 99 flags signal wait_mpj $ns2
Greg Kroah-Hartman
maintainerPATCH 378/567 kbuild: Leave objtool binary around with make clean
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
[ Upstream commit fdb12c8a24a453bdd6759979b6ef1e04ebd4beb4 ]
The difference between 'make clean' and 'make mrproper' is documented in 'make help' as:
clean - Remove most generated files but keep the config and
enough build support to build external modules
mrproper - Remove all generated files + config + various backup files
After commit 68b4fe32d737 ("kbuild: Add objtool to top-level clean target"), running 'make clean' then attempting to build an external module with the resulting build directory fails with
$ make ARCH=x86_64 O=build clean
$ make -C build M=... MO=... ... /bin/sh: line 1: .../build/tools/objtool/objtool: No such file or directory
as 'make clean' removes the objtool binary.
Split the objtool clean target into mrproper and clean like Kbuild does and remove all generated artifacts with 'make clean' except for the objtool binary, which is removed with 'make mrproper'. To avoid a small race when running the objtool clean target through both objtool_mrproper and objtool_clean when running 'make mrproper', modify objtool's clean up find command to avoid using find's '-delete' command by piping the files into 'xargs rm -f' like the rest of Kbuild does.
--- Makefile | 8 ++++---- tools/objtool/Makefile | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-)
Makefile +4 -4
@@ -1356,13 +1356,13 @@ ifneq ($(wildcard $(resolve_btfids_O)),) $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean endif -PHONY += objtool_clean +PHONY += objtool_clean objtool_mrproper objtool_O = $(abspath $(objtree))/tools/objtool -objtool_clean: +objtool_clean objtool_mrproper: ifneq ($(wildcard $(objtool_O)),) - $(Q)$(MAKE) -sC $(abs_srctree)/tools/objtool O=$(objtool_O) srctree=$(abs_srctree) clean + $(Q)$(MAKE) -sC $(abs_srctree)/tools/objtool O=$(objtool_O) srctree=$(abs_srctree) $(patsubst objtool_%,%,$@) endif tools/: FORCE
@@ -1529,7 +1529,7 @@ PHONY += $(mrproper-dirs) mrproper $(mrproper-dirs): $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) -mrproper: clean $(mrproper-dirs) +mrproper: clean objtool_mrproper $(mrproper-dirs) $(call cmd,rmfiles) @find . $(RCS_FIND_IGNORE) \ \( -name '*.rmeta' \) \
tools/objtool/Makefile +5 -3
@@ -87,10 +87,12 @@ $(LIBSUBCMD)-clean: $(Q)$(RM) -r -- $(LIBSUBCMD_OUTPUT) clean: $(LIBSUBCMD)-clean - $(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL) - $(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete + $(Q)find $(OUTPUT) \( -name '*.o' -o -name '\.*.cmd' -o -name '\.*.d' \) -type f -print | xargs $(RM) $(Q)$(RM) $(OUTPUT)arch/x86/lib/inat-tables.c $(OUTPUT)fixdep +mrproper: clean + $(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL) + FORCE: -.PHONY: clean FORCE +.PHONY: clean mrproper FORCE
Greg Kroah-Hartman
maintainerPATCH 379/567 net/sched: act_gate: snapshot parameters with RCU on replace
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Moses <[email protected]>
[ Upstream commit 62413a9c3cb183afb9bb6e94dd68caf4e4145f4c ]
The gate action can be replaced while the hrtimer callback or dump path is walking the schedule list.
Convert the parameters to an RCU-protected snapshot and swap updates under tcf_lock, freeing the previous snapshot via call_rcu(). When REPLACE omits the entry list, preserve the existing schedule so the effective state is unchanged.
--- include/net/tc_act/tc_gate.h | 33 ++++- net/sched/act_gate.c | 266 ++++++++++++++++++++++++++++++------------- 2 files changed, 212 insertions(+), 87 deletions(-)
include/net/tc_act/tc_gate.h +26 -7
@@ -32,6 +32,7 @@ struct tcf_gate_params {s32 tcfg_clockid;size_t num_entries;struct list_head entries; +struct rcu_head rcu; };#define GATE_ACT_GATE_OPEN BIT(0)
@@ -39,7 +40,7 @@ struct tcf_gate_params {struct tcf_gate {struct tc_action common; -struct tcf_gate_params param; +struct tcf_gate_params __rcu *param;u8 current_gate_status;ktime_t current_close_time;u32 current_entry_octets;
@@ -60,47 +61,65 @@ static inline bool is_tcf_gate(const strreturn false; } +static inline struct tcf_gate_params *tcf_gate_params_locked (const struct tc_action *a) +{ +struct tcf_gate *gact =to_gate (a); + +return rcu_dereference_protected (gact->param, +lockdep_is_held (&gact->tcf_lock)); +} +static inline s32 tcf_gate_prio (const struct tc_action *a) { +struct tcf_gate_params *p;s32 tcfg_prio; - tcfg_prio =to_gate (a)->param.tcfg_priority; + p =tcf_gate_params_locked (a); + tcfg_prio = p->tcfg_priority;return tcfg_prio; }static inline u64 tcf_gate_basetime (const struct tc_action *a) { +struct tcf_gate_params *p;u64 tcfg_basetime; - tcfg_basetime =to_gate (a)->param.tcfg_basetime; + p =tcf_gate_params_locked (a); + tcfg_basetime = p->tcfg_basetime;return tcfg_basetime; }static inline u64 tcf_gate_cycletime (const struct tc_action *a) { +struct tcf_gate_params *p;u64 tcfg_cycletime; - tcfg_cycletime =to_gate (a)->param.tcfg_cycletime; + p =tcf_gate_params_locked (a); + tcfg_cycletime = p->tcfg_cycletime;return tcfg_cycletime; }static inline u64 tcf_gate_cycletimeext (const struct tc_action *a) { +struct tcf_gate_params *p;u64 tcfg_cycletimeext; - tcfg_cycletimeext =to_gate (a)->param.tcfg_cycletime_ext; + p =tcf_gate_params_locked (a); + tcfg_cycletimeext = p->tcfg_cycletime_ext;return tcfg_cycletimeext; }static inline u32 tcf_gate_num_entries (const struct tc_action *a) { +struct tcf_gate_params *p;u32 num_entries; - num_entries =to_gate (a)->param.num_entries; + p =tcf_gate_params_locked (a); + num_entries = p->num_entries;return num_entries; }
@@ -114,7 +133,7 @@ static inline struct action_gate_entryu32 num_entries;int i =0 ; - p = &to_gate (a)->param; + p =tcf_gate_params_locked (a); num_entries = p->num_entries;list_for_each_entry (entry, &p->entries, list)
net/sched/act_gate.c +186 -80
384 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 380/567 can: gs_usb: gs_can_open(): always configure bitrates before starting device
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Kleine-Budde <[email protected]>
[ Upstream commit 2df6162785f31f1bbb598cfc3b08e4efc88f80b6 ]
So far the driver populated the struct can_priv::do_set_bittiming() and struct can_priv::fd::do_set_data_bittiming() callbacks.
Before bringing up the interface, user space has to configure the bitrates. With these callbacks the configuration is directly forwarded into the CAN hardware. Then the interface can be brought up.
An ifdown-ifup cycle (without changing the bit rates) doesn't re-configure the bitrates in the CAN hardware. This leads to a problem with the CANable-2.5 [1] firmware, which resets the configured bit rates during ifdown.
To fix the problem remove both bit timing callbacks and always configure the bitrates in the struct net_device_ops::ndo_open() callback.
[1] https://github.com/Elmue/CANable-2.5-firmware-Slcan-and-Candlelight
--- drivers/net/can/usb/gs_usb.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/net/can/usb/gs_usb.c +16 -6
@@ -769,9 +769,8 @@ device_detach: } } -static int gs_usb_set_bittiming (struct net_device *netdev) +static int gs_usb_set_bittiming (struct gs_can *dev) { -struct gs_can *dev =netdev_priv (netdev);struct can_bittiming *bt = &dev->can.bittiming;struct gs_device_bittiming dbt = { .prop_seg =cpu_to_le32 (bt->prop_seg),
@@ -788,9 +787,8 @@ static int gs_usb_set_bittiming(struct n GFP_KERNEL); } -static int gs_usb_set_data_bittiming (struct net_device *netdev) +static int gs_usb_set_data_bittiming (struct gs_can *dev) { -struct gs_can *dev =netdev_priv (netdev);struct can_bittiming *bt = &dev->can.data_bittiming;struct gs_device_bittiming dbt = { .prop_seg =cpu_to_le32 (bt->prop_seg),
@@ -1054,6 +1052,20 @@ static int gs_can_open(struct net_deviceif (dev->feature &GS_CAN_FEATURE_HW_TIMESTAMP ) flags |=GS_CAN_MODE_HW_TIMESTAMP ; + rc =gs_usb_set_bittiming (dev); +if (rc) { +netdev_err (netdev,"failed to set bittiming: %pe\n" ,ERR_PTR (rc)); + goto out_usb_kill_anchored_urbs; + } + +if (ctrlmode &CAN_CTRLMODE_FD ) { + rc =gs_usb_set_data_bittiming (dev); +if (rc) { +netdev_err (netdev,"failed to set data bittiming: %pe\n" ,ERR_PTR (rc)); + goto out_usb_kill_anchored_urbs; + } + } +/* finally start device */ dev->can.state =CAN_STATE_ERROR_ACTIVE ; dm.flags =cpu_to_le32 (flags);
@@ -1354,7 +1366,6 @@ static struct gs_can *gs_make_candev(uns dev->can.state =CAN_STATE_STOPPED ; dev->can.clock.freq =le32_to_cpu (bt_const.fclk_can); dev->can.bittiming_const = &dev->bt_const; - dev->can.do_set_bittiming = gs_usb_set_bittiming; dev->can.ctrlmode_supported =CAN_CTRLMODE_CC_LEN8_DLC ;
@@ -1378,7 +1389,6 @@ static struct gs_can *gs_make_candev(uns* GS_CAN_FEATURE_BT_CONST_EXT is set. */ dev->can.data_bittiming_const = &dev->bt_const; - dev->can.do_set_data_bittiming = gs_usb_set_data_bittiming; }if (feature &GS_CAN_FEATURE_TERMINATION ) {
Greg Kroah-Hartman
maintainerPATCH 381/567 usb: gadget: f_tcm: Fix NULL pointer dereferences in nexus handling
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiasheng Jiang <[email protected]>
[ Upstream commit b9fde507355342a2d64225d582dc8b98ff5ecb19 ]
The tpg->tpg_nexus pointer in the USB Target driver is dynamically managed and tied to userspace configuration via ConfigFS. It can be NULL if the USB host sends requests before the nexus is fully established or immediately after it is dropped.
Currently, functions like bot_submit_command() and the data transfer paths retrieve tv_nexus = tpg->tpg_nexus and immediately dereference tv_nexus->tvn_se_sess without any validation. If a malicious or misconfigured USB host sends a BOT (Bulk-Only Transport) command during this race window, it triggers a NULL pointer dereference, leading to a kernel panic (local DoS).
This exposes an inconsistent API usage within the module, as peer functions like usbg_submit_command() and bot_send_bad_response() correctly implement a NULL check for tv_nexus before proceeding.
Fix this by bringing consistency to the nexus handling. Add the missing if (!tv_nexus) checks to the vulnerable BOT command and request processing paths, aborting the command gracefully with an error instead of crashing the system.
--- drivers/usb/gadget/function/f_tcm.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/usb/gadget/function/f_tcm.c +14 -0
@@ -1032,6 +1032,13 @@ static void usbg_cmd_work(struct work_st se_cmd = &cmd->se_cmd; tpg = cmd->fu->tpg; tv_nexus = tpg->tpg_nexus; +if (!tv_nexus) { +struct usb_gadget *gadget =fuas_to_gadget (cmd->fu); + +dev_err (&gadget->dev,"Missing nexus, ignoring command\n" ); +return ; + } + dir =get_cmd_dir (cmd->cmd_buf);if (dir <0 ) { __target_init_cmd(se_cmd,
@@ -1160,6 +1167,13 @@ static void bot_cmd_work(struct work_str se_cmd = &cmd->se_cmd; tpg = cmd->fu->tpg; tv_nexus = tpg->tpg_nexus; +if (!tv_nexus) { +struct usb_gadget *gadget =fuas_to_gadget (cmd->fu); + +dev_err (&gadget->dev,"Missing nexus, ignoring command\n" ); +return ; + } + dir =get_cmd_dir (cmd->cmd_buf);if (dir <0 ) { __target_init_cmd(se_cmd,
Greg Kroah-Hartman
maintainerPATCH 382/567 KVM: SVM: Limit AVIC physical max index based on configured max_vcpu_ids
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Naveen N Rao <[email protected]>
[ Upstream commit 574ef752d4aea04134bc121294d717f4422c2755 ]
KVM allows VMMs to specify the maximum possible APIC ID for a virtual machine through KVM_CAP_MAX_VCPU_ID capability so as to limit data structures related to APIC/x2APIC. Utilize the same to set the AVIC physical max index in the VMCB, similar to VMX. This helps hardware limit the number of entries to be scanned in the physical APIC ID table speeding up IPI broadcasts for virtual machines with smaller number of vCPUs.
Unlike VMX, SVM AVIC requires a single page to be allocated for the Physical APIC ID table and the Logical APIC ID table, so retain the existing approach of allocating those during VM init.
Stable-dep-of: 87d0f901a9bd ("KVM: SVM: Set/clear CR8 write interception when AVIC is (de)activated")
--- arch/x86/kvm/svm/avic.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/x86/kvm/svm/avic.c +5 -2
@@ -85,6 +85,7 @@ struct amd_svm_iommu_ir {static void avic_activate_vmcb (struct vcpu_svm *svm) {struct vmcb *vmcb = svm->vmcb01.ptr; +struct kvm *kvm = svm->vcpu.kvm; vmcb->control.int_ctl &= ~(AVIC_ENABLE_MASK |X2APIC_MODE_MASK ); vmcb->control.avic_physical_id &= ~AVIC_PHYSICAL_MAX_INDEX_MASK ;
@@ -100,7 +101,8 @@ static void avic_activate_vmcb(struct vc*/ if (x2avic_enabled &&apic_x2apic_mode (svm->vcpu.arch.apic)) { vmcb->control.int_ctl |=X2APIC_MODE_MASK ; - vmcb->control.avic_physical_id |=X2AVIC_MAX_PHYSICAL_ID ; + vmcb->control.avic_physical_id |=min (kvm->arch.max_vcpu_ids -1 , +X2AVIC_MAX_PHYSICAL_ID );/* Disabling MSR intercept for x2APIC registers */ svm_set_x2apic_msr_interception (svm, false); }else {
@@ -111,7 +113,8 @@ static void avic_activate_vmcb(struct vckvm_make_request (KVM_REQ_TLB_FLUSH_CURRENT , &svm->vcpu);/* For xAVIC and hybrid-xAVIC modes */ - vmcb->control.avic_physical_id |=AVIC_MAX_PHYSICAL_ID ; + vmcb->control.avic_physical_id |=min (kvm->arch.max_vcpu_ids -1 , +AVIC_MAX_PHYSICAL_ID );/* Enabling MSR intercept for x2APIC registers */ svm_set_x2apic_msr_interception (svm, true); }
Greg Kroah-Hartman
maintainerPATCH 383/567 KVM: SVM: Add a helper to look up the max physical ID for AVIC
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Naveen N Rao <[email protected]>
[ Upstream commit f2f6e67a56dc88fea7e9b10c4e79bb01d97386b7 ]
To help with a future change, add a helper to look up the maximum physical ID depending on the vCPU AVIC mode. No functional change intended.
Stable-dep-of: 87d0f901a9bd ("KVM: SVM: Set/clear CR8 write interception when AVIC is (de)activated")
--- arch/x86/kvm/svm/avic.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
arch/x86/kvm/svm/avic.c +20 -6
@@ -82,13 +82,31 @@ struct amd_svm_iommu_ir {void *data;/* Storing pointer to struct amd_ir_data */ }; +static u32 avic_get_max_physical_id (struct kvm_vcpu *vcpu) +{ +u32 arch_max; + +if (x2avic_enabled &&apic_x2apic_mode (vcpu->arch.apic)) + arch_max =X2AVIC_MAX_PHYSICAL_ID ; +else + arch_max =AVIC_MAX_PHYSICAL_ID ; + +/* +* Despite its name, KVM_CAP_MAX_VCPU_ID represents the maximum APIC ID +* plus one, so the max possible APIC ID is one less than that. +*/ +return min (vcpu->kvm->arch.max_vcpu_ids -1 , arch_max); +} +static void avic_activate_vmcb (struct vcpu_svm *svm) {struct vmcb *vmcb = svm->vmcb01.ptr; -struct kvm *kvm = svm->vcpu.kvm; +struct kvm_vcpu *vcpu = &svm->vcpu; vmcb->control.int_ctl &= ~(AVIC_ENABLE_MASK |X2APIC_MODE_MASK ); + vmcb->control.avic_physical_id &= ~AVIC_PHYSICAL_MAX_INDEX_MASK ; + vmcb->control.avic_physical_id |=avic_get_max_physical_id (vcpu); vmcb->control.int_ctl |=AVIC_ENABLE_MASK ;
@@ -101,8 +119,7 @@ static void avic_activate_vmcb(struct vc*/ if (x2avic_enabled &&apic_x2apic_mode (svm->vcpu.arch.apic)) { vmcb->control.int_ctl |=X2APIC_MODE_MASK ; - vmcb->control.avic_physical_id |=min (kvm->arch.max_vcpu_ids -1 , -X2AVIC_MAX_PHYSICAL_ID ); +/* Disabling MSR intercept for x2APIC registers */ svm_set_x2apic_msr_interception (svm, false); }else {
@@ -112,9 +129,6 @@ static void avic_activate_vmcb(struct vc*/ kvm_make_request (KVM_REQ_TLB_FLUSH_CURRENT , &svm->vcpu); -/* For xAVIC and hybrid-xAVIC modes */ - vmcb->control.avic_physical_id |=min (kvm->arch.max_vcpu_ids -1 , -AVIC_MAX_PHYSICAL_ID );/* Enabling MSR intercept for x2APIC registers */ svm_set_x2apic_msr_interception (svm, true); }
Greg Kroah-Hartman
maintainerPATCH 384/567 KVM: SVM: Set/clear CR8 write interception when AVIC is (de)activated
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit 87d0f901a9bd8ae6be57249c737f20ac0cace93d ]
Explicitly set/clear CR8 write interception when AVIC is (de)activated to fix a bug where KVM leaves the interception enabled after AVIC is activated. E.g. if KVM emulates INIT=>WFS while AVIC is deactivated, CR8 will remain intercepted in perpetuity.
On its own, the dangling CR8 intercept is "just" a performance issue, but combined with the TPR sync bug fixed by commit d02e48830e3f ("KVM: SVM:
Sync TPR from LAPIC into VMCB::V_TPR even if AVIC is active"), the danging intercept is fatal to Windows guests as the TPR seen by hardware gets wildly out of sync with reality.
Note, VMX isn't affected by the bug as TPR_THRESHOLD is explicitly ignored when Virtual Interrupt Delivery is enabled, i.e. when APICv is active in KVM's world. I.e. there's no need to trigger update_cr8_intercept(), this is firmly an SVM implementation flaw/detail.
WARN if KVM gets a CR8 write #VMEXIT while AVIC is active, as KVM should never enter the guest with AVIC enabled and CR8 writes intercepted.
--- arch/x86/kvm/svm/avic.c | 7 +++++-- arch/x86/kvm/svm/svm.c | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-)
arch/x86/kvm/svm/avic.c +5 -2
@@ -104,12 +104,12 @@ static void avic_activate_vmcb(struct vcstruct kvm_vcpu *vcpu = &svm->vcpu; vmcb->control.int_ctl &= ~(AVIC_ENABLE_MASK |X2APIC_MODE_MASK ); - vmcb->control.avic_physical_id &= ~AVIC_PHYSICAL_MAX_INDEX_MASK ; vmcb->control.avic_physical_id |=avic_get_max_physical_id (vcpu); - vmcb->control.int_ctl |=AVIC_ENABLE_MASK ; +svm_clr_intercept (svm,INTERCEPT_CR8_WRITE ); +/* * Note: KVM supports hybrid-AVIC mode, where KVM emulates x2APIC MSR * accesses, while interrupt injection to a running vCPU can be
@@ -141,6 +141,9 @@ static void avic_deactivate_vmcb(struct vmcb->control.int_ctl &= ~(AVIC_ENABLE_MASK |X2APIC_MODE_MASK ); vmcb->control.avic_physical_id &= ~AVIC_PHYSICAL_MAX_INDEX_MASK ; +if (!sev_es_guest (svm->vcpu.kvm)) +svm_set_intercept (svm,INTERCEPT_CR8_WRITE ); +/* * If running nested and the guest uses its own MSR bitmap, there * is no need to update L0's msr bitmap
arch/x86/kvm/svm/svm.c +4 -3
@@ -1261,8 +1261,7 @@ static void init_vmcb(struct kvm_vcpu *vsvm_set_intercept (svm,INTERCEPT_CR0_WRITE );svm_set_intercept (svm,INTERCEPT_CR3_WRITE );svm_set_intercept (svm,INTERCEPT_CR4_WRITE ); -if (!kvm_vcpu_apicv_active (vcpu)) -svm_set_intercept (svm,INTERCEPT_CR8_WRITE ); +svm_set_intercept (svm,INTERCEPT_CR8_WRITE );set_dr_intercepts (svm);
@@ -2806,9 +2805,11 @@ static int dr_interception(struct kvm_vcstatic int cr8_write_interception (struct kvm_vcpu *vcpu) { +u8 cr8_prev =kvm_get_cr8 (vcpu);int r; -u8 cr8_prev =kvm_get_cr8 (vcpu); +WARN_ON_ONCE (kvm_vcpu_apicv_active (vcpu)); +/* instruction emulation calls kvm_set_cr8() */ r =cr_interception (vcpu);if (lapic_in_kernel (vcpu))
Greg Kroah-Hartman
maintainerPATCH 385/567 mm/kfence: fix KASAN hardware tag faults during late enablement
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Potapenko <[email protected]>
[ Upstream commit d155aab90fffa00f93cea1f107aef0a3d548b2ff ]
When KASAN hardware tags are enabled, re-enabling KFENCE late (via /sys/module/kfence/parameters/sample_interval) causes KASAN faults.
This happens because the KFENCE pool and metadata are allocated via the page allocator, which tags the memory, while KFENCE continues to access it using untagged pointers during initialization.
Use __GFP_SKIP_KASAN for late KFENCE pool and metadata allocations to ensure the memory remains untagged, consistent with early allocations from memblock. To support this, add __GFP_SKIP_KASAN to the allowlist in __alloc_contig_verify_gfp_mask().
--- mm/kfence/core.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
mm/kfence/core.c +8 -6
@@ -945,14 +945,14 @@ static int kfence_init_late(void)#ifdef CONFIG_CONTIG_ALLOC struct page *pages; - pages =alloc_contig_pages (nr_pages_pool,GFP_KERNEL , first_online_node, -NULL ); + pages =alloc_contig_pages (nr_pages_pool,GFP_KERNEL | __GFP_SKIP_KASAN, + first_online_node,NULL );if (!pages)return -ENOMEM ; __kfence_pool =page_to_virt (pages); - pages =alloc_contig_pages (nr_pages_meta,GFP_KERNEL , first_online_node, -NULL ); + pages =alloc_contig_pages (nr_pages_meta,GFP_KERNEL | __GFP_SKIP_KASAN, + first_online_node,NULL );if (pages) kfence_metadata_init =page_to_virt (pages);#else
@@ -962,11 +962,13 @@ static int kfence_init_late(void) return -EINVAL; } - __kfence_pool =alloc_pages_exact (KFENCE_POOL_SIZE ,GFP_KERNEL ); + __kfence_pool =alloc_pages_exact (KFENCE_POOL_SIZE , +GFP_KERNEL | __GFP_SKIP_KASAN);if (!__kfence_pool)return -ENOMEM ; - kfence_metadata_init =alloc_pages_exact (KFENCE_METADATA_SIZE ,GFP_KERNEL ); + kfence_metadata_init =alloc_pages_exact (KFENCE_METADATA_SIZE , +GFP_KERNEL | __GFP_SKIP_KASAN);#endif if (!kfence_metadata_init)
Greg Kroah-Hartman
maintainerPATCH 386/567 iomap: reject delalloc mappings during writeback
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Darrick J. Wong" <[email protected]>
[ Upstream commit d320f160aa5ff36cdf83c645cca52b615e866e32 ]
Filesystems should never provide a delayed allocation mapping to writeback; they're supposed to allocate the space before replying. This can lead to weird IO errors and crashes in the block layer if the filesystem is being malicious, or if it hadn't set iomap->dev because it's a delalloc mapping.
Fix this by failing writeback on delalloc mappings. Currently no filesystems actually misbehave in this manner, but we ought to be stricter about things like that.
--- fs/iomap/buffered-io.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
fs/iomap/buffered-io.c +12 -3
@@ -1838,10 +1838,19 @@ iomap_writepage_map(struct iomap_writepaif (error)break ;trace_iomap_writepage_map (inode, &wpc->iomap); -if (WARN_ON_ONCE (wpc->iomap.type ==IOMAP_INLINE )) -continue ; -if (wpc->iomap.type ==IOMAP_HOLE ) +switch (wpc->iomap.type) { +case IOMAP_UNWRITTEN : +case IOMAP_MAPPED : +break ; +case IOMAP_HOLE :continue ; +default : +WARN_ON_ONCE (1 ); + error = -EIO ; +break ; + } +if (error) +break ;iomap_add_to_ioend (inode, pos, folio, ifs, wpc, wbc, &submit_list); count++;
Greg Kroah-Hartman
maintainerPATCH 387/567 ksmbd: Dont log keys in SMB3 signing and encryption key generation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit 441336115df26b966575de56daf7107ed474faed ]
When KSMBD_DEBUG_AUTH logging is enabled, generate_smb3signingkey() and generate_smb3encryptionkey() log the session, signing, encryption, and decryption key bytes. Remove the logs to avoid exposing credentials.
--- fs/smb/server/auth.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-)
fs/smb/server/auth.c +2 -20
@@ -797,12 +797,8 @@ static int generate_smb3signingkey(strucif (!(conn->dialect >=SMB30_PROT_ID && signing->binding))memcpy (chann->smb3signingkey, key,SMB3_SIGN_KEY_SIZE ); -ksmbd_debug (AUTH ,"dumping generated AES signing keys\n" ); +ksmbd_debug (AUTH ,"generated SMB3 signing key\n" );ksmbd_debug (AUTH ,"Session Id %llu\n" , sess->id); -ksmbd_debug (AUTH ,"Session Key %*ph\n" , -SMB2_NTLMV2_SESSKEY_SIZE , sess->sess_key); -ksmbd_debug (AUTH ,"Signing Key %*ph\n" , -SMB3_SIGN_KEY_SIZE , key);return 0 ; }
@@ -866,23 +862,9 @@ static int generate_smb3encryptionkey(stif (rc)return rc; -ksmbd_debug (AUTH ,"dumping generated AES encryption keys\n" ); +ksmbd_debug (AUTH ,"generated SMB3 encryption/decryption keys\n" );ksmbd_debug (AUTH ,"Cipher type %d\n" , conn->cipher_type);ksmbd_debug (AUTH ,"Session Id %llu\n" , sess->id); -ksmbd_debug (AUTH ,"Session Key %*ph\n" , -SMB2_NTLMV2_SESSKEY_SIZE , sess->sess_key); -if (conn->cipher_type ==SMB2_ENCRYPTION_AES256_CCM || - conn->cipher_type ==SMB2_ENCRYPTION_AES256_GCM ) { -ksmbd_debug (AUTH ,"ServerIn Key %*ph\n" , -SMB3_GCM256_CRYPTKEY_SIZE , sess->smb3encryptionkey); -ksmbd_debug (AUTH ,"ServerOut Key %*ph\n" , -SMB3_GCM256_CRYPTKEY_SIZE , sess->smb3decryptionkey); - }else { -ksmbd_debug (AUTH ,"ServerIn Key %*ph\n" , -SMB3_GCM128_CRYPTKEY_SIZE , sess->smb3encryptionkey); -ksmbd_debug (AUTH ,"ServerOut Key %*ph\n" , -SMB3_GCM128_CRYPTKEY_SIZE , sess->smb3decryptionkey); - }return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 388/567 drm/msm: Fix dma_free_attrs() buffer size
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit e4eb6e4dd6348dd00e19c2275e3fbaed304ca3bd ]
The gpummu->table buffer is alloc'd with size TABLE_SIZE + 32 in a2xx_gpummu_new() but freed with size TABLE_SIZE in a2xx_gpummu_destroy().
Change the free size to match the allocation.
Patchwork: https://patchwork.freedesktop.org/patch/707340/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/msm_gpummu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_gpummu.c +1 -1
@@ -76,7 +76,7 @@ static void msm_gpummu_destroy(struct ms {struct msm_gpummu *gpummu =to_msm_gpummu (mmu); -dma_free_attrs (mmu->dev,TABLE_SIZE , gpummu->table, gpummu->pt_base, +dma_free_attrs (mmu->dev,TABLE_SIZE +32 , gpummu->table, gpummu->pt_base,DMA_ATTR_FORCE_CONTIGUOUS );kfree (gpummu);
Greg Kroah-Hartman
maintainerPATCH 389/567 drm/bridge: ti-sn65dsi83: halve horizontal syncs for dual LVDS output
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Ceresoli <[email protected]>
[ Upstream commit d0d727746944096a6681dc6adb5f123fc5aa018d ]
Dual LVDS output (available on the SN65DSI84) requires HSYNC_PULSE_WIDTH and HORIZONTAL_BACK_PORCH to be divided by two with respect to the values used for single LVDS output.
While not clearly stated in the datasheet, this is needed according to the DSI Tuner [0] output. It also makes sense intuitively because in dual LVDS output two pixels at a time are output and so the output clock is half of the pixel clock.
Some dual-LVDS panels refuse to show any picture without this fix.
Divide by two HORIZONTAL_FRONT_PORCH too, even though this register is used only for test pattern generation which is not currently implemented by this driver.
[0] https://www.ti.com/tool/DSI-TUNER
--- drivers/gpu/drm/bridge/ti-sn65dsi83.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/ti-sn65dsi83.c +4 -3
@@ -325,6 +325,7 @@ static void sn65dsi83_atomic_pre_enable( struct drm_bridge_state *old_bridge_state) {struct sn65dsi83 *ctx =bridge_to_sn65dsi83 (bridge); +const unsigned int dual_factor = ctx->lvds_dual_link ?2 :1 ;struct drm_atomic_state *state = old_bridge_state->base.state;const struct drm_bridge_state *bridge_state;const struct drm_crtc_state *crtc_state;
@@ -452,18 +453,18 @@ static void sn65dsi83_atomic_pre_enable(/* 32 + 1 pixel clock to ensure proper operation */ le16val =cpu_to_le16 (32 +1 );regmap_bulk_write (ctx->regmap,REG_VID_CHA_SYNC_DELAY_LOW , &le16val,2 ); - le16val =cpu_to_le16 (mode->hsync_end - mode->hsync_start); + le16val =cpu_to_le16 ((mode->hsync_end - mode->hsync_start) / dual_factor);regmap_bulk_write (ctx->regmap,REG_VID_CHA_HSYNC_PULSE_WIDTH_LOW , &le16val,2 ); le16val =cpu_to_le16 (mode->vsync_end - mode->vsync_start);regmap_bulk_write (ctx->regmap,REG_VID_CHA_VSYNC_PULSE_WIDTH_LOW , &le16val,2 );regmap_write (ctx->regmap,REG_VID_CHA_HORIZONTAL_BACK_PORCH , - mode->htotal - mode->hsync_end); + (mode->htotal - mode->hsync_end) / dual_factor);regmap_write (ctx->regmap,REG_VID_CHA_VERTICAL_BACK_PORCH , mode->vtotal - mode->vsync_end);regmap_write (ctx->regmap,REG_VID_CHA_HORIZONTAL_FRONT_PORCH , - mode->hsync_start - mode->hdisplay); + (mode->hsync_start - mode->hdisplay) / dual_factor);regmap_write (ctx->regmap,REG_VID_CHA_VERTICAL_FRONT_PORCH , mode->vsync_start - mode->vdisplay);regmap_write (ctx->regmap,REG_VID_CHA_TEST_PATTERN ,0x00 );
Greg Kroah-Hartman
maintainerPATCH 390/567 net: macb: Shuffle the tx ring before enabling tx
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kevin Hao <[email protected]>
[ Upstream commit 881a0263d502e1a93ebc13a78254e9ad19520232 ]
Quanyang observed that when using an NFS rootfs on an AMD ZynqMp board, the rootfs may take an extended time to recover after a suspend. Upon investigation, it was determined that the issue originates from a problem in the macb driver.
According to the Zynq UltraScale TRM [1], when transmit is disabled, the transmit buffer queue pointer resets to point to the address specified by the transmit buffer queue base address register.
In the current implementation, the code merely resets queue->tx_head and queue->tx_tail to '0'. This approach presents several issues:
- Packets already queued in the tx ring are silently lost, leading to memory leaks since the associated skbs cannot be released.
- Concurrent write access to queue->tx_head and queue->tx_tail may occur from macb_tx_poll() or macb_start_xmit() when these values are reset to '0'.
- The transmission may become stuck on a packet that has already been sent out, with its 'TX_USED' bit set, but has not yet been processed. However, due to the manipulation of 'queue->tx_head' and 'queue->tx_tail', macb_tx_poll() incorrectly assumes there are no packets to handle because queue->tx_head == queue->tx_tail. This issue is only resolved when a new packet is placed at this position. This is the root cause of the prolonged recovery time observed for the NFS root filesystem.
To resolve this issue, shuffle the tx ring and tx skb array so that the first unsent packet is positioned at the start of the tx ring. Additionally, ensure that updates to queue->tx_head and queue->tx_tail are properly protected with the appropriate lock.
[1] https://docs.amd.com/v/u/en-US/ug1085-zynq-ultrascale-trm
--- drivers/net/ethernet/cadence/macb_main.c | 98 ++++++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 3 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +95 -3
@@ -38,6 +38,7 @@#include <linux/ptp_classify.h> #include <linux/reset.h> #include <linux/firmware/xlnx-zynqmp.h> +#include <linux/gcd.h> #include "macb.h" /* This structure is only used for MACB on SiFive FU540 devices */
@@ -719,6 +720,97 @@ static void macb_mac_link_down(struct phnetif_tx_stop_all_queues (ndev); } +/* Use juggling algorithm to left rotate tx ring and tx skb array */ +static void gem_shuffle_tx_one_ring (struct macb_queue *queue) +{ +unsigned int head, tail, count, ring_size, desc_size; +struct macb_tx_skb tx_skb, *skb_curr, *skb_next; +struct macb_dma_desc *desc_curr, *desc_next; +unsigned int i, cycles, shift, curr, next; +struct macb *bp = queue->bp; +unsigned char desc[24 ]; +unsigned long flags; + + desc_size =macb_dma_desc_get_size (bp); + +if (WARN_ON_ONCE (desc_size >ARRAY_SIZE (desc))) +return ; + +spin_lock_irqsave (&queue->tx_ptr_lock, flags); + head = queue->tx_head; + tail = queue->tx_tail; + ring_size = bp->tx_ring_size; + count =CIRC_CNT (head, tail, ring_size); + +if (!(tail % ring_size)) + goto unlock; + +if (!count) { + queue->tx_head =0 ; + queue->tx_tail =0 ; + goto unlock; + } + + shift = tail % ring_size; + cycles =gcd (ring_size, shift); + +for (i =0 ; i < cycles; i++) { +memcpy (&desc,macb_tx_desc (queue, i), desc_size); +memcpy (&tx_skb,macb_tx_skb (queue, i), +sizeof (struct macb_tx_skb )); + + curr = i; + next = (curr + shift) % ring_size; + +while (next != i) { + desc_curr =macb_tx_desc (queue, curr); + desc_next =macb_tx_desc (queue, next); + +memcpy (desc_curr, desc_next, desc_size); + +if (next == ring_size -1 ) + desc_curr->ctrl &= ~MACB_BIT (TX_WRAP ); +if (curr == ring_size -1 ) + desc_curr->ctrl |=MACB_BIT (TX_WRAP ); + + skb_curr =macb_tx_skb (queue, curr); + skb_next =macb_tx_skb (queue, next); +memcpy (skb_curr, skb_next,sizeof (struct macb_tx_skb )); + + curr = next; + next = (curr + shift) % ring_size; + } + + desc_curr =macb_tx_desc (queue, curr); +memcpy (desc_curr, &desc, desc_size); +if (i == ring_size -1 ) + desc_curr->ctrl &= ~MACB_BIT (TX_WRAP ); +if (curr == ring_size -1 ) + desc_curr->ctrl |=MACB_BIT (TX_WRAP ); +memcpy (macb_tx_skb (queue, curr), &tx_skb, +sizeof (struct macb_tx_skb )); + } + + queue->tx_head = count; + queue->tx_tail =0 ; + +/* Make descriptor updates visible to hardware */ +wmb (); + +unlock: +spin_unlock_irqrestore (&queue->tx_ptr_lock, flags); +} + +/* Rotate the queue so that the tail is at index 0 */ +static void gem_shuffle_tx_rings (struct macb *bp) +{ +struct macb_queue *queue; +int q; + +for (q =0 , queue = bp->queues; q < bp->num_queues; q++, queue++) +gem_shuffle_tx_one_ring (queue); +} + static void macb_mac_link_up(struct phylink_config *config, struct phy_device *phy, unsigned int mode, phy_interface_t interface,
@@ -757,8 +849,6 @@ static void macb_mac_link_up(struct phyl ctrl |=MACB_BIT (PAE );for (q =0 , queue = bp->queues; q < bp->num_queues; ++q, ++queue) { - queue->tx_head =0 ; - queue->tx_tail =0 ;queue_writel (queue,IER , bp->rx_intr_mask |MACB_TX_INT_FLAGS |MACB_BIT (HRESP )); }
@@ -772,8 +862,10 @@ static void macb_mac_link_up(struct phylspin_unlock_irqrestore (&bp->lock, flags); -if (!(bp->caps &MACB_CAPS_MACB_IS_EMAC )) +if (!(bp->caps &MACB_CAPS_MACB_IS_EMAC )) {macb_set_tx_clk (bp, speed); +gem_shuffle_tx_rings (bp); + }/* Enable Rx and Tx; Enable PTP unicast */ ctrl =macb_readl (bp,NCR );
Greg Kroah-Hartman
maintainerPATCH 391/567 cifs: open files should not hold ref on superblock
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shyam Prasad N <[email protected]>
[ Upstream commit 340cea84f691c5206561bb2e0147158fe02070be ]
Today whenever we deal with a file, in addition to holding a reference on the dentry, we also get a reference on the superblock. This happens in two cases:
1. when a new cinode is allocated
2. when an oplock break is being processed
The reasoning for holding the superblock ref was to make sure that when umount happens, if there are users of inodes and dentries, it does not try to clean them up and wait for the last ref to superblock to be dropped by last of such users.
But the side effect of doing that is that umount silently drops a ref on the superblock and we could have deferred closes and lease breaks still holding these refs.
Ideally, we should ensure that all of these users of inodes and dentries are cleaned up at the time of umount, which is what this code is doing.
This code change allows these code paths to use a ref on the dentry (and hence the inode). That way, umount is ensured to clean up SMB client resources when it's the last ref on the superblock (For ex: when same objects are shared).
The code change also moves the call to close all the files in deferred close list to the umount code path. It also waits for oplock_break workers to be flushed before calling kill_anon_super (which eventually frees up those objects).
--- fs/smb/client/cifsfs.c | 7 +++++-- fs/smb/client/cifsproto.h | 1 + fs/smb/client/file.c | 11 ----------- fs/smb/client/misc.c | 43 +++++++++++++++++++++++++++++++++++++++++++ fs/smb/client/trace.h | 2 ++ 5 files changed, 51 insertions(+), 13 deletions(-)
fs/smb/client/cifsfs.c +5 -2
@@ -290,10 +290,14 @@ static void cifs_kill_sb(struct super_bl/* * We need to release all dentries for the cached directories -* before we kill the sb. +* and close all deferred file handles before we kill the sb. */ if (cifs_sb->root) {close_all_cached_dirs (cifs_sb); +cifs_close_all_deferred_files_sb (cifs_sb); + +/* Wait for all pending oplock breaks to complete */ +flush_workqueue (cifsoplockd_wq);/* finally release root dentry */ dput (cifs_sb->root);
@@ -768,7 +772,6 @@ static void cifs_umount_begin(struct supspin_unlock (&tcon->tc_lock);spin_unlock (&cifs_tcp_ses_lock); -cifs_close_all_deferred_files (tcon);/* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */ /* cancel_notify_requests(tcon); */ if (tcon->ses && tcon->ses->server) {
fs/smb/client/cifsproto.h +1 -0
@@ -300,6 +300,7 @@ extern void cifs_close_deferred_file(strextern void cifs_close_all_deferred_files (struct cifs_tcon *cifs_tcon); +void cifs_close_all_deferred_files_sb (struct cifs_sb_info *cifs_sb);extern void cifs_close_deferred_file_under_dentry (struct cifs_tcon *cifs_tcon,const char *path);
fs/smb/client/file.c +0 -11
@@ -579,8 +579,6 @@ struct cifsFileInfo *cifs_new_fileinfo(smutex_init (&cfile->fh_mutex);spin_lock_init (&cfile->file_info_lock); -cifs_sb_active (inode->i_sb); -/* * If the server returned a read oplock and we have mandatory brlocks, * set oplock level to None.
@@ -635,7 +633,6 @@ static void cifsFileInfo_put_final(strucstruct inode *inode =d_inode (cifs_file->dentry);struct cifsInodeInfo *cifsi =CIFS_I (inode);struct cifsLockInfo *li, *tmp; -struct super_block *sb = inode->i_sb;/* * Delete any outstanding lock records. We'll lose them when the file
@@ -653,7 +650,6 @@ static void cifsFileInfo_put_final(struccifs_put_tlink (cifs_file->tlink);dput (cifs_file->dentry); -cifs_sb_deactive (sb);kfree (cifs_file->symlink_target);kfree (cifs_file); }
@@ -5154,12 +5150,6 @@ void cifs_oplock_break(struct work_struc__u64 persistent_fid, volatile_fid;__u16 net_fid; -/* -* Hold a reference to the superblock to prevent it and its inodes from -* being freed while we are accessing cinode. Otherwise, _cifsFileInfo_put() -* may release the last reference to the sb and trigger inode eviction. -*/ -cifs_sb_active (sb);wait_on_bit (&cinode->flags,CIFS_INODE_PENDING_WRITERS ,TASK_UNINTERRUPTIBLE );
@@ -5232,7 +5222,6 @@ oplock_break_ack:cifs_put_tlink (tlink); out:cifs_done_oplock_break (cinode); -cifs_sb_deactive (sb); }/*
fs/smb/client/misc.c +43 -0
55 lines not on this page · raw message
fs/smb/client/trace.h +2 -0
@@ -30,6 +30,7 @@ EM(netfs_trace_tcon_ref_get_cached_laundromat, "GET Ch-Lau") \ EM(netfs_trace_tcon_ref_get_cached_lease_break, "GET Ch-Lea") \ EM(netfs_trace_tcon_ref_get_cancelled_close, "GET Cn-Cls") \ + EM(netfs_trace_tcon_ref_get_close_defer_files, "GET Cl-Def") \ EM(netfs_trace_tcon_ref_get_dfs_refer, "GET DfsRef") \ EM(netfs_trace_tcon_ref_get_find, "GET Find ") \EM (netfs_trace_tcon_ref_get_find_sess_tcon,"GET FndSes" ) \
@@ -41,6 +42,7 @@ EM(netfs_trace_tcon_ref_put_cancelled_close, "PUT Cn-Cls") \ EM(netfs_trace_tcon_ref_put_cancelled_close_fid, "PUT Cn-Fid") \ EM(netfs_trace_tcon_ref_put_cancelled_mid, "PUT Cn-Mid") \ + EM(netfs_trace_tcon_ref_put_close_defer_files, "PUT Cl-Def") \ EM(netfs_trace_tcon_ref_put_mnt_ctx, "PUT MntCtx") \ EM(netfs_trace_tcon_ref_put_dfs_refer, "PUT DfsRfr") \EM (netfs_trace_tcon_ref_put_reconnect_server,"PUT Reconn" ) \
Greg Kroah-Hartman
maintainerPATCH 392/567 crypto: atmel-sha204a - Fix OOM ->tfm_count leak
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit d240b079a37e90af03fd7dfec94930eb6c83936e ]
If memory allocation fails, decrement ->tfm_count to avoid blocking future reads.
--- drivers/crypto/atmel-sha204a.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/crypto/atmel-sha204a.c +3 -2
@@ -52,9 +52,10 @@ static int atmel_sha204a_rng_read_nonblo rng->priv =0 ; }else { work_data =kmalloc (sizeof (*work_data),GFP_ATOMIC ); -if (!work_data) +if (!work_data) { +atomic_dec (&i2c_priv->tfm_count);return -ENOMEM ; - + } work_data->ctx = i2c_priv; work_data->client = i2c_priv->client;
Greg Kroah-Hartman
maintainerPATCH 393/567 xfs: fix integer overflow in bmap intent sort comparator
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Long Li <[email protected]>
[ Upstream commit 362c490980867930a098b99f421268fbd7ca05fd ]
xfs_bmap_update_diff_items() sorts bmap intents by inode number using a subtraction of two xfs_ino_t (uint64_t) values, with the result truncated to int. This is incorrect when two inode numbers differ by more than INT_MAX (2^31 - 1), which is entirely possible on large XFS filesystems.
Fix this by replacing the subtraction with cmp_int().
--- fs/xfs/xfs_bmap_item.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/xfs/xfs_bmap_item.c +2 -1
@@ -278,7 +278,8 @@ xfs_bmap_update_diff_items( ba = container_of(a, struct xfs_bmap_intent, bi_list); bb = container_of(b, struct xfs_bmap_intent, bi_list); -return ba->bi_owner->i_ino - bb->bi_owner->i_ino; +return (ba->bi_owner->i_ino > bb->bi_owner->i_ino) - + (ba->bi_owner->i_ino < bb->bi_owner->i_ino); }/* Set the map extent flags for this mapping. */
Greg Kroah-Hartman
maintainerPATCH 394/567 xfs: ensure dquot item is deleted from AIL only after log shutdown
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Long Li <[email protected]>
[ Upstream commit 186ac39b8a7d3ec7ce9c5dd45e5c2730177f375c ]
In xfs_qm_dqflush(), when a dquot flush fails due to corruption (the out_abort error path), the original code removed the dquot log item from the AIL before calling xfs_force_shutdown(). This ordering introduces a subtle race condition that can lead to data loss after a crash.
The AIL tracks the oldest dirty metadata in the journal. The position of the tail item in the AIL determines the log tail LSN, which is the oldest LSN that must be preserved for crash recovery. When an item is removed from the AIL, the log tail can advance past the LSN of that item.
The race window is as follows: if the dquot item happens to be at the tail of the log, removing it from the AIL allows the log tail to advance. If a concurrent log write is sampling the tail LSN at the same time and subsequently writes a complete checkpoint (i.e., one containing a commit record) to disk before the shutdown takes effect, the journal will no longer protect the dquot's last modification. On the next mount, log recovery will not replay the dquot changes, even though they were never written back to disk, resulting in silent data loss.
Fix this by calling xfs_force_shutdown() before xfs_trans_ail_delete() in the out_abort path. Once the log is shut down, no new log writes can complete with an updated tail LSN, making it safe to remove the dquot item from the AIL.
--- fs/xfs/xfs_dquot.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/xfs/xfs_dquot.c +7 -1
@@ -1297,9 +1297,15 @@ xfs_qm_dqflush(return 0 ; out_abort: +/* +* Shut down the log before removing the dquot item from the AIL. +* Otherwise, the log tail may advance past this item's LSN while +* log writes are still in progress, making these unflushed changes +* unrecoverable on the next mount. +*/ +xfs_force_shutdown (mp,SHUTDOWN_CORRUPT_INCORE ); dqp->q_flags &= ~XFS_DQFLAG_DIRTY ;xfs_trans_ail_delete (lip,0 ); -xfs_force_shutdown (mp,SHUTDOWN_CORRUPT_INCORE ); out_unlock:xfs_dqfunlock (dqp);return error;
Greg Kroah-Hartman
maintainerPATCH 395/567 smb: client: Compare MACs in constant time
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 26bc83b88bbbf054f0980a4a42047a8d1e210e4c upstream.
To prevent timing attacks, MAC comparisons need to be constant-time. Replace the memcmp() with the correct function, crypto_memneq().
--- fs/smb/client/cifsencrypt.c | 3 ++- fs/smb/client/smb2transport.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-)
fs/smb/client/cifsencrypt.c +2 -1
@@ -23,6 +23,7 @@#include <linux/fips.h> #include "../common/arc4.h" #include <crypto/aead.h> +#include <crypto/utils.h> /* * Hash data from a BVEC-type iterator.
@@ -371,7 +372,7 @@ int cifs_verify_signature(struct smb_rqs/* cifs_dump_mem("what we think it should be: ", what_we_think_sig_should_be, 16); */ -if (memcmp (server_response_sig, what_we_think_sig_should_be,8 )) +if (crypto_memneq (server_response_sig, what_we_think_sig_should_be,8 ))return -EACCES ;else return 0 ;
fs/smb/client/smb2transport.c +3 -1
@@ -19,6 +19,7 @@#include <linux/mempool.h> #include <linux/highmem.h> #include <crypto/aead.h> +#include <crypto/utils.h> #include "cifsglob.h" #include "cifsproto.h" #include "smb2proto.h"
@@ -732,7 +733,8 @@ smb2_verify_signature(struct smb_rqst *rif (rc)return rc; -if (memcmp (server_response_sig, shdr->Signature,SMB2_SIGNATURE_SIZE )) { +if (crypto_memneq (server_response_sig, shdr->Signature, +SMB2_SIGNATURE_SIZE )) {cifs_dbg (VFS ,"sign fail cmd 0x%x message id 0x%llx\n" , shdr->Command, shdr->MessageId);return -EACCES ;
Greg Kroah-Hartman
maintainerPATCH 396/567 ksmbd: Compare MACs in constant time
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit c5794709bc9105935dbedef8b9cf9c06f2b559fa upstream.
To prevent timing attacks, MAC comparisons need to be constant-time. Replace the memcmp() with the correct function, crypto_memneq().
--- fs/smb/server/Kconfig | 1 + fs/smb/server/auth.c | 4 +++- fs/smb/server/smb2pdu.c | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-)
fs/smb/server/Kconfig +1 -0
@@ -11,6 +11,7 @@ config SMB_SERVER select CRYPTO_HMAC select CRYPTO_ECB select CRYPTO_LIB_DES + select CRYPTO_LIB_UTILS select CRYPTO_SHA256 select CRYPTO_CMAC select CRYPTO_SHA512
fs/smb/server/auth.c +3 -1
@@ -13,6 +13,7 @@#include <linux/xattr.h> #include <crypto/hash.h> #include <crypto/aead.h> +#include <crypto/utils.h> #include <linux/random.h> #include <linux/scatterlist.h>
@@ -283,7 +284,8 @@ int ksmbd_auth_ntlmv2(struct ksmbd_conn goto out; } -if (memcmp (ntlmv2->ntlmv2_hash, ntlmv2_rsp,CIFS_HMAC_MD5_HASH_SIZE ) !=0 ) +if (crypto_memneq (ntlmv2->ntlmv2_hash, ntlmv2_rsp, +CIFS_HMAC_MD5_HASH_SIZE )) rc = -EINVAL ; out:if (ctx)
fs/smb/server/smb2pdu.c +3 -2
@@ -4,6 +4,7 @@* Copyright (C) 2018 Samsung Electronics Co., Ltd. */ +#include <crypto/utils.h> #include <linux/inetdevice.h> #include <net/addrconf.h> #include <linux/syscalls.h>
@@ -8804,7 +8805,7 @@ int smb2_check_sign_req(struct ksmbd_wor signature))return 0 ; -if (memcmp (signature, signature_req,SMB2_SIGNATURE_SIZE )) { +if (crypto_memneq (signature, signature_req,SMB2_SIGNATURE_SIZE )) {pr_err ("bad smb2 signature\n" );return 0 ; }
@@ -8892,7 +8893,7 @@ int smb3_check_sign_req(struct ksmbd_worif (ksmbd_sign_smb3_pdu (conn, signing_key, iov,1 , signature))return 0 ; -if (memcmp (signature, signature_req,SMB2_SIGNATURE_SIZE )) { +if (crypto_memneq (signature, signature_req,SMB2_SIGNATURE_SIZE )) {pr_err ("bad smb2 signature\n" );return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 397/567 net/tcp-md5: Fix MAC comparison to be constant-time
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 46d0d6f50dab706637f4c18a470aac20a21900d3 upstream.
To prevent timing attacks, MACs need to be compared in constant time. Use the appropriate helper function for this.
--- net/ipv4/tcp.c | 3 ++- net/ipv4/tcp_ipv4.c | 3 ++- net/ipv6/tcp_ipv6.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-)
net/ipv4/tcp.c +2 -1
@@ -244,6 +244,7 @@#define pr_fmt (fmt) "TCP: " fmt#include <crypto/hash.h> +#include <crypto/utils.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/types.h>
@@ -4556,7 +4557,7 @@ tcp_inbound_md5_hash(const struct sock * hash_expected, NULL, skb); -if (genhash ||memcmp (hash_location, newhash,16 ) !=0 ) { +if (genhash ||crypto_memneq (hash_location, newhash,16 )) {NET_INC_STATS (sock_net (sk),LINUX_MIB_TCPMD5FAILURE );if (family ==AF_INET ) { net_info_ratelimited("MD5 Hash failed for (%pI4, %d)->(%pI4, %d)%s L3 index %d\n",
net/ipv4/tcp_ipv4.c +2 -1
@@ -80,6 +80,7 @@#include <linux/btf_ids.h> #include <crypto/hash.h> +#include <crypto/utils.h> #include <linux/scatterlist.h> #include <trace/events/tcp.h>
@@ -776,7 +777,7 @@ static void tcp_v4_send_reset(const stru genhash =tcp_v4_md5_hash_skb (newhash, key,NULL , skb); -if (genhash ||memcmp (hash_location, newhash,16 ) !=0 ) +if (genhash ||crypto_memneq (hash_location, newhash,16 )) goto out; }
net/ipv6/tcp_ipv6.c +2 -1
@@ -64,6 +64,7 @@#include <linux/seq_file.h> #include <crypto/hash.h> +#include <crypto/utils.h> #include <linux/scatterlist.h> #include <trace/events/tcp.h>
@@ -1035,7 +1036,7 @@ static void tcp_v6_send_reset(const stru goto out; genhash =tcp_v6_md5_hash_skb (newhash, key,NULL , skb); -if (genhash ||memcmp (hash_location, newhash,16 ) !=0 ) +if (genhash ||crypto_memneq (hash_location, newhash,16 )) goto out; }#endif
Greg Kroah-Hartman
maintainerPATCH 398/567 f2fs: fix to avoid migrating empty section
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit d625a2b08c089397d3a03bff13fa8645e4ec7a01 ]
It reports a bug from device w/ zufs:
F2FS-fs (dm-64): Inconsistent segment (173822) type [1, 0] in SSA and SIT F2FS-fs (dm-64): Stopped filesystem due to reason: 4
Thread A Thread B
- f2fs_expand_inode_data
- f2fs_allocate_pinning_section
- f2fs_gc_range
- do_garbage_collect w/ segno #x
- writepage
- f2fs_allocate_data_block
- new_curseg
- allocate segno #x
The root cause is: fallocate on pinning file may race w/ block allocation as above, result in do_garbage_collect() from fallocate() may migrate segment which is just allocated by a log, the log will update segment type in its in-memory structure, however GC will get segment type from on-disk SSA block, once segment type changes by log, we can detect such inconsistency, then shutdown filesystem.
In this case, on-disk SSA shows type of segno #173822 is 1 (SUM_TYPE_NODE), however segno #173822 was just allocated as data type segment, so in-memory SIT shows type of segno #173822 is 0 (SUM_TYPE_DATA).
Change as below to fix this issue:
- check whether current section is empty before gc
- add sanity checks on do_garbage_collect() to avoid any race case, result in migrating segment used by log.
- btw, it fixes misc issue in printed logs: "SSA and SIT" -> "SIT and SSA".
[ Use IS_CURSEC instead of is_cursec according to commit c1cfc87e49525 ("f2fs: introduce is_cur{seg,sec}()"). ]
--- fs/f2fs/gc.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
fs/f2fs/gc.c +15 -1
@@ -1742,6 +1742,13 @@ static int do_garbage_collect(struct f2f GET_SUM_BLOCK(sbi, segno));f2fs_put_page (sum_page,0 ); +if (IS_CURSEC (sbi,GET_SEC_FROM_SEG (sbi, segno))) { +f2fs_err (sbi,"%s: segment %u is used by log" , + __func__, segno); +f2fs_bug_on (sbi,1 ); + goto skip; + } +if (get_valid_blocks (sbi, segno, false) ==0 ) goto freed; if (gc_type == BG_GC && __is_large_section(sbi) &&
@@ -1752,7 +1759,7 @@ static int do_garbage_collect(struct f2f sum =page_address (sum_page);if (type !=GET_SUM_TYPE ((&sum->footer))) { -f2fs_err (sbi,"Inconsistent segment (%u) type [%d, %d] in SSA and SIT" , +f2fs_err (sbi,"Inconsistent segment (%u) type [%d, %d] in SIT and SSA" , segno, type,GET_SUM_TYPE ((&sum->footer)));set_sbi_flag (sbi,SBI_NEED_FSCK ); f2fs_stop_checkpoint(sbi, false,
@@ -2005,6 +2012,13 @@ int f2fs_gc_range(struct f2fs_sb_info *s .iroot = RADIX_TREE_INIT(gc_list.iroot, GFP_NOFS), }; +/* +* avoid migrating empty section, as it can be allocated by +* log in parallel. +*/ +if (!get_valid_blocks (sbi, segno, true)) +continue ; +do_garbage_collect (sbi, segno, &gc_list,FG_GC , dry_run_sections ==0 );put_gc_inode (&gc_list);
Greg Kroah-Hartman
maintainerPATCH 399/567 ext4: fix dirtyclusters double decrement on fs shutdown
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Foster <[email protected]>
[ Upstream commit 94a8cea54cd935c54fa2fba70354757c0fc245e3 ]
fstests test generic/388 occasionally reproduces a warning in ext4_put_super() associated with the dirty clusters count:
WARNING: CPU: 7 PID: 76064 at fs/ext4/super.c:1324 ext4_put_super+0x48c/0x590 [ext4]
Tracing the failure shows that the warning fires due to an s_dirtyclusters_counter value of -1. IOW, this appears to be a spurious decrement as opposed to some sort of leak. Further tracing of the dirty cluster count deltas and an LLM scan of the resulting output identified the cause as a double decrement in the error path between ext4_mb_mark_diskspace_used() and the caller ext4_mb_new_blocks().
First, note that generic/388 is a shutdown vs. fsstress test and so produces a random set of operations and shutdown injections. In the problematic case, the shutdown triggers an error return from the ext4_handle_dirty_metadata() call(s) made from ext4_mb_mark_context(). The changed value is non-zero at this point, so ext4_mb_mark_diskspace_used() does not exit after the error bubbles up from ext4_mb_mark_context(). Instead, the former decrements both cluster counters and returns the error up to ext4_mb_new_blocks(). The latter falls into the !ar->len out path which decrements the dirty clusters counter a second time, creating the inconsistency.
To avoid this problem and simplify ownership of the cluster reservation in this codepath, lift the counter reduction to a single place in the caller. This makes it more clear that ext4_mb_new_blocks() is responsible for acquiring cluster reservation (via ext4_claim_free_clusters()) in the !delalloc case as well as releasing it, regardless of whether it ends up consumed or returned due to failure.
--- fs/ext4/mballoc.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-)
fs/ext4/mballoc.c +5 -16
@@ -3999,8 +3999,7 @@ void ext4_exit_mballoc(void)* Returns 0 if success or error code */ static noinline_for_stack int -ext4_mb_mark_diskspace_used (struct ext4_allocation_context *ac, -handle_t *handle,unsigned int reserv_clstrs) +ext4_mb_mark_diskspace_used (struct ext4_allocation_context *ac,handle_t *handle) {struct buffer_head *bitmap_bh =NULL ;struct ext4_group_desc *gdp;
@@ -4086,13 +4085,6 @@ ext4_mb_mark_diskspace_used(struct ext4_ext4_unlock_group (sb, ac->ac_b_ex.fe_group);percpu_counter_sub (&sbi->s_freeclusters_counter, ac->ac_b_ex.fe_len); -/* -* Now reduce the dirty block count also. Should not go negative -*/ -if (!(ac->ac_flags &EXT4_MB_DELALLOC_RESERVED )) -/* release all the reserved blocks if non delalloc */ -percpu_counter_sub (&sbi->s_dirtyclusters_counter, - reserv_clstrs);if (sbi->s_log_groups_per_flex) { ext4_group_t flex_group = ext4_flex_group(sbi,
@@ -6265,7 +6257,7 @@ repeat:ext4_mb_pa_put_free (ac); }if (likely (ac->ac_status ==AC_STATUS_FOUND )) { - *errp =ext4_mb_mark_diskspace_used (ac, handle, reserv_clstrs); + *errp =ext4_mb_mark_diskspace_used (ac, handle);if (*errp) {ext4_discard_allocated_blocks (ac); goto errout;
@@ -6296,12 +6288,9 @@ errout: out:if (inquota && ar->len < inquota)dquot_free_block (ar->inode,EXT4_C2B (sbi, inquota - ar->len)); -if (!ar->len) { -if ((ar->flags &EXT4_MB_DELALLOC_RESERVED ) ==0 ) -/* release all the reserved blocks if non delalloc */ -percpu_counter_sub (&sbi->s_dirtyclusters_counter, - reserv_clstrs); - } +/* release any reserved blocks */ +if (reserv_clstrs) +percpu_counter_sub (&sbi->s_dirtyclusters_counter, reserv_clstrs);trace_ext4_allocate_blocks (ar, (unsigned long long )block);
Greg Kroah-Hartman
maintainerPATCH 400/567 btrfs: always fallback to buffered write if the inode requires checksum
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
commit 968f19c5b1b7d5595423b0ac0020cc18dfed8cb5 upstream.
[BUG]
It is a long known bug that VM image on btrfs can lead to data csum mismatch, if the qemu is using direct-io for the image (this is commonly known as cache mode 'none').
[CAUSE]
Inside the VM, if the fs is EXT4 or XFS, or even NTFS from Windows, the fs is allowed to dirty/modify the folio even if the folio is under writeback (as long as the address space doesn't have AS_STABLE_WRITES flag inherited from the block device).
This is a valid optimization to improve the concurrency, and since these filesystems have no extra checksum on data, the content change is not a problem at all.
But the final write into the image file is handled by btrfs, which needs the content not to be modified during writeback, or the checksum will not match the data (checksum is calculated before submitting the bio).
So EXT4/XFS/NTRFS assume they can modify the folio under writeback, but btrfs requires no modification, this leads to the false csum mismatch.
This is only a controlled example, there are even cases where multi-thread programs can submit a direct IO write, then another thread modifies the direct IO buffer for whatever reason.
For such cases, btrfs has no sane way to detect such cases and leads to false data csum mismatch.
[FIX]
I have considered the following ideas to solve the problem:
- Make direct IO to always skip data checksum
This not only requires a new incompatible flag, as it breaks the current per-inode NODATASUM flag.
But also requires extra handling for no csum found cases.
And this also reduces our checksum protection.
- Let hardware handle all the checksum
AKA, just nodatasum mount option.
That requires trust for hardware (which is not that trustful in a lot of cases), and it's not generic at all.
- Always fallback to buffered write if the inode requires checksum This was suggested by Christoph, and is the solution utilized by this patch.
The cost is obvious, the extra buffer copying into page cache, thus it reduces the performance.
But at least it's still user configurable, if the end user still wants the zero-copy performance, just set NODATASUM flag for the inode (which is a common practice for VM images on btrfs).
Since we cannot trust user space programs to keep the buffer consistent during direct IO, we have no choice but always falling back to buffered IO. At least by this, we avoid the more deadly false data checksum mismatch error.
--- fs/btrfs/file.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
fs/btrfs/file.c +16 -0
@@ -1514,6 +1514,22 @@ relock:btrfs_inode_unlock (BTRFS_I (inode), ilock_flags); goto buffered; } +/* +* We can't control the folios being passed in, applications can write +* to them while a direct IO write is in progress. This means the +* content might change after we calculated the data checksum. +* Therefore we can end up storing a checksum that doesn't match the +* persisted data. +* +* To be extra safe and avoid false data checksum mismatch, if the +* inode requires data checksum, just fallback to buffered IO. +* For buffered IO we have full control of page cache and can ensure +* no one is modifying the content during writeback. +*/ +if (!(BTRFS_I (inode)->flags &BTRFS_INODE_NODATASUM )) { +btrfs_inode_unlock (BTRFS_I (inode), ilock_flags); + goto buffered; + }/* * The iov_iter can be mapped to the same file range we are writing to.
Greg Kroah-Hartman
maintainerPATCH 401/567 net: stmmac: dwmac-loongson: Set clk_csr_i to 100-150MHz
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huacai Chen <[email protected]>
commit e1aa5ef892fb4fa9014a25e87b64b97347919d37 upstream.
Current clk_csr_i setting of Loongson STMMAC (including LS7A1000/2000 and LS2K1000/2000/3000) are copy & paste from other drivers. In fact, Loongson STMMAC use 125MHz clocks and need 62 freq division to within 2.5MHz, meeting most PHY MDC requirement. So fix by setting clk_csr_i to 100-150MHz, otherwise some PHYs may link fail.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +1 -1
@@ -14,7 +14,7 @@static int loongson_default_data (struct plat_stmmacenet_data *plat) { - plat->clk_csr =2 ;/* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */ + plat->clk_csr =1 ;/* clk_csr_i = 100-150MHz & MDC = clk_csr_i/62 */ plat->has_gmac =1 ; plat->force_sf_dma_mode =1 ;