qed: Fix the VF msix vectors flow
Subsystems (5)
Sasha Levin
maintainerPATCH 1/7 qed: Fix the VF msix vectors flow
From: Shai Malin <[email protected]>
[ Upstream commit b0cd08537db8d2fbb227cdb2e5835209db295a24 ]
For VFs we should return with an error in case we didn't get the exact number of msix vectors as we requested.
Not doing that will lead to a crash when starting queues for this VF.
--- drivers/net/ethernet/qlogic/qed/qed_main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/qlogic/qed/qed_main.c +6 -1
@@ -437,7 +437,12 @@ static int qed_enable_msix(struct qed_dev *cdev, rc = cnt; } -if (rc >0 ) { +/* For VFs, we should return with an error in case we didn't get the +* exact number of msix vectors as we requested. +* Not doing that will lead to a crash when starting queues for +* this VF. +*/ +if ((IS_PF (cdev) && rc >0 ) || (IS_VF (cdev) && rc == cnt)) {/* MSI-x configuration was achieved */ int_params->out.int_mode =QED_INT_MODE_MSIX ; int_params->out.num_vectors = rc;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 2/7 net: macb: Add a NULL check on desc_ptp
From: Harini Katakam <[email protected]>
[ Upstream commit 85520079afce885b80647fbd0d13d8f03d057167 ]
macb_ptp_desc will not return NULL under most circumstances with correct Kconfig and IP design config register. But for the sake of the extreme corner case, check for NULL when using the helper. In case of rx_tstamp, no action is necessary except to return (similar to timestamp disabled) and warn. In case of TX, return -EINVAL to let the skb be free. Perform this check before marking skb in progress.
Fixes coverity warning:
(4) Event dereference:
Dereferencing a null pointer "desc_ptp"
--- drivers/net/ethernet/cadence/macb_ptp.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/net/ethernet/cadence/macb_ptp.c +10 -1
@@ -286,6 +286,12 @@ void gem_ptp_rxstamp(struct macb *bp, struct sk_buff *skb,if (GEM_BFEXT (DMA_RXVALID , desc->addr)) { desc_ptp =macb_ptp_desc (bp, desc); +/* Unlikely but check */ +if (!desc_ptp) { +dev_warn_ratelimited (&bp->pdev->dev, +"Timestamp not supported in BD\n" ); +return ; + }gem_hw_timestamp (bp, desc_ptp->ts_1, desc_ptp->ts_2, &ts);memset (shhwtstamps,0 ,sizeof (struct skb_shared_hwtstamps )); shhwtstamps->hwtstamp =ktime_set (ts.tv_sec, ts.tv_nsec);
@@ -318,8 +324,11 @@ int gem_ptp_txstamp(struct macb_queue *queue, struct sk_buff *skb,if (CIRC_SPACE (head, tail,PTP_TS_BUFFER_SIZE ) ==0 )return -ENOMEM ; -skb_shinfo (skb)->tx_flags |=SKBTX_IN_PROGRESS ; desc_ptp =macb_ptp_desc (queue->bp, desc); +/* Unlikely but check */ +if (!desc_ptp) +return -EINVAL ; +skb_shinfo (skb)->tx_flags |=SKBTX_IN_PROGRESS ; tx_timestamp = &queue->tx_timestamps[head]; tx_timestamp->skb = skb; tx_timestamp->desc_ptp.ts_1 = desc_ptp->ts_1;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 3/7 qede: Fix memset corruption
In reply to Sasha LevinFrom: Shai Malin <[email protected]>
[ Upstream commit e543468869e2532f5d7926e8f417782b48eca3dc ]
Thanks to Kees Cook who detected the problem of memset that starting from not the first member, but sized for the whole struct. The better change will be to remove the redundant memset and to clear only the msix_cnt member.
--- drivers/net/ethernet/qlogic/qede/qede_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/qlogic/qede/qede_main.c +1 -1
@@ -1590,6 +1590,7 @@ static void qede_sync_free_irqs(struct qede_dev *edev) } edev->int_info.used_cnt =0 ; + edev->int_info.msix_cnt =0 ; }static int qede_req_msix_irqs (struct qede_dev *edev)
@@ -2088,7 +2089,6 @@ static int qede_load(struct qede_dev *edev, enum qede_load_mode mode, goto out; err4:qede_sync_free_irqs (edev); -memset (&edev->int_info.msix_cnt,0 ,sizeof (struct qed_int_info )); err3:qede_napi_disable_remove (edev); err2:
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 4/7 perf/x86/intel/pt: Fix mask of num_address_ranges
In reply to Sasha LevinFrom: Xiaoyao Li <[email protected]>
[ Upstream commit c53c6b7409f4cd9e542991b53d597fbe2751d7db ]
Per SDM, bit 2:0 of CPUID(0x14,1).EAX[2:0] reports the number of configurable address ranges for filtering, not bit 1:0.
--- arch/x86/events/intel/pt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/intel/pt.c +1 -1
@@ -69,7 +69,7 @@ static struct pt_cap_desc {PT_CAP (topa_multiple_entries,0 ,CPUID_ECX ,BIT (1 )),PT_CAP (single_range_output,0 ,CPUID_ECX ,BIT (2 )),PT_CAP (payloads_lip,0 ,CPUID_ECX ,BIT (31 )), -PT_CAP (num_address_ranges,1 ,CPUID_EAX ,0x3 ), +PT_CAP (num_address_ranges,1 ,CPUID_EAX ,0x7 ),PT_CAP (mtc_periods,1 ,CPUID_EAX ,0xffff0000 ),PT_CAP (cycle_thresholds,1 ,CPUID_EBX ,0xffff ), PT_CAP(psb_periods, 1, CPUID_EBX, 0xffff0000),
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 5/7 perf/x86/amd/ibs: Work around erratum #1197
In reply to Sasha LevinFrom: Kim Phillips <[email protected]>
[ Upstream commit 26db2e0c51fe83e1dd852c1321407835b481806e ]
Erratum #1197 "IBS (Instruction Based Sampling) Register State May be Incorrect After Restore From CC6" is published in a document:
"Revision Guide for AMD Family 19h Models 00h-0Fh Processors" 56683 Rev. 1.04 July 2021
https://bugzilla.kernel.org/show_bug.cgi?id=206537
Implement the erratum's suggested workaround and ignore IBS samples if MSRC001_1031 == 0.
--- arch/x86/events/amd/ibs.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/x86/events/amd/ibs.c +8 -0
@@ -90,6 +90,7 @@ struct perf_ibs {unsigned long offset_mask[1 ];int offset_max; unsigned int fetch_count_reset_broken : 1; + unsigned int fetch_ignore_if_zero_rip : 1;struct cpu_perf_ibs __percpu *pcpu;struct attribute **format_attrs;
@@ -674,6 +675,10 @@ static int perf_ibs_handle_irq(struct perf_ibs *perf_ibs, struct pt_regs *iregs)if (check_rip && (ibs_data.regs[2 ] &IBS_RIP_INVALID )) { regs.flags &= ~PERF_EFLAGS_EXACT ; }else { +/* Workaround for erratum #1197 */ +if (perf_ibs->fetch_ignore_if_zero_rip && !(ibs_data.regs[1 ])) + goto out; +set_linear_ip (®s, ibs_data.regs[1 ]); regs.flags |=PERF_EFLAGS_EXACT ; }
@@ -767,6 +772,9 @@ static __init void perf_event_ibs_init(void)if (boot_cpu_data.x86 >=0x16 && boot_cpu_data.x86 <=0x18 ) perf_ibs_fetch.fetch_count_reset_broken =1 ; +if (boot_cpu_data.x86 ==0x19 && boot_cpu_data.x86_model <0x10 ) + perf_ibs_fetch.fetch_ignore_if_zero_rip =1 ; +perf_ibs_pmu_init (&perf_ibs_fetch,"ibs_fetch" );if (ibs_caps &IBS_CAPS_OPCNT ) {
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 6/7 net: fix NULL pointer reference in cipso_v4_doi_free
In reply to Sasha LevinFrom: 王贇 <[email protected]>
[ Upstream commit 733c99ee8be9a1410287cdbb943887365e83b2d6 ]
In netlbl_cipsov4_add_std() when 'doi_def->map.std' alloc failed, we sometime observe panic:
BUG: kernel NULL pointer dereference, address: ... RIP: 0010:cipso_v4_doi_free+0x3a/0x80 ... Call Trace: netlbl_cipsov4_add_std+0xf4/0x8c0 netlbl_cipsov4_add+0x13f/0x1b0 genl_family_rcv_msg_doit.isra.15+0x132/0x170 genl_rcv_msg+0x125/0x240
This is because in cipso_v4_doi_free() there is no check on 'doi_def->map.std' when 'doi_def->type' equal 1, which is possibe, since netlbl_cipsov4_add_std() haven't initialize it before alloc 'doi_def->map.std'.
This patch just add the check to prevent panic happen for similar cases.
--- net/ipv4/cipso_ipv4.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
net/ipv4/cipso_ipv4.c +10 -8
@@ -480,14 +480,16 @@ void cipso_v4_doi_free(struct cipso_v4_doi *doi_def)if (!doi_def)return ; -switch (doi_def->type) { -case CIPSO_V4_MAP_TRANS : -kfree (doi_def->map.std->lvl.cipso); -kfree (doi_def->map.std->lvl.local); -kfree (doi_def->map.std->cat.cipso); -kfree (doi_def->map.std->cat.local); -kfree (doi_def->map.std); -break ; +if (doi_def->map.std) { +switch (doi_def->type) { +case CIPSO_V4_MAP_TRANS : +kfree (doi_def->map.std->lvl.cipso); +kfree (doi_def->map.std->lvl.local); +kfree (doi_def->map.std->cat.cipso); +kfree (doi_def->map.std->cat.local); +kfree (doi_def->map.std); +break ; + } }kfree (doi_def); }
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 7/7 cryptoloop: add a deprecation warning
In reply to Sasha LevinFrom: Christoph Hellwig <[email protected]>
[ Upstream commit 222013f9ac30b9cec44301daa8dbd0aae38abffb ]
Support for cryptoloop has been officially marked broken and deprecated in favor of dm-crypt (which supports the same broken algorithms if needed) in Linux 2.6.4 (released in March 2004), and support for it has been entirely removed from losetup in util-linux 2.23 (released in April 2013). Add a warning and a deprecation schedule.
--- drivers/block/Kconfig | 4 ++-- drivers/block/cryptoloop.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/block/Kconfig +2 -2
@@ -234,7 +234,7 @@ config BLK_DEV_LOOP_MIN_COUNT dynamically allocated with the /dev/loop-control interface. config BLK_DEV_CRYPTOLOOP - tristate "Cryptoloop Support" + tristate "Cryptoloop Support (DEPRECATED)" select CRYPTO select CRYPTO_CBC depends on BLK_DEV_LOOP
@@ -246,7 +246,7 @@ config BLK_DEV_CRYPTOLOOP WARNING: This device is not safe for journaled file systems like ext3 or Reiserfs. Please use the Device Mapper crypto module instead, which can be configured to be on-disk compatible with the - cryptoloop device. + cryptoloop device. cryptoloop support will be removed in Linux 5.16. source "drivers/block/drbd/Kconfig"
drivers/block/cryptoloop.c +2 -0
@@ -203,6 +203,8 @@ init_cryptoloop(void)if (rc)printk (KERN_ERR "cryptoloop: loop_register_transfer failed\n" ); +else +pr_warn ("the cryptoloop driver has been deprecated and will be removed in in Linux 5.16\n" );return rc; }
Signature · 1 line
2.30.2