From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Guangwu Zhang <guazhang@redhat.com>,
Saurav Kashyap <skashyap@marvell.com>,
John Meneghini <jmeneghi@redhat.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>
Subject: [PATCH 5.15 083/110] scsi: bnx2fc: Make bnx2fc_recv_frame() mp safe
Date: Mon, 7 Feb 2022 12:06:56 +0100 [thread overview]
Message-ID: <20220207103805.208752206@linuxfoundation.org> (raw)
In-Reply-To: <20220207103802.280120990@linuxfoundation.org>
From: John Meneghini <jmeneghi@redhat.com>
commit 936bd03405fc83ba039d42bc93ffd4b88418f1d3 upstream.
Running tests with a debug kernel shows that bnx2fc_recv_frame() is
modifying the per_cpu lport stats counters in a non-mpsafe way. Just boot
a debug kernel and run the bnx2fc driver with the hardware enabled.
[ 1391.699147] BUG: using smp_processor_id() in preemptible [00000000] code: bnx2fc_
[ 1391.699160] caller is bnx2fc_recv_frame+0xbf9/0x1760 [bnx2fc]
[ 1391.699174] CPU: 2 PID: 4355 Comm: bnx2fc_l2_threa Kdump: loaded Tainted: G B
[ 1391.699180] Hardware name: HP ProLiant DL120 G7, BIOS J01 07/01/2013
[ 1391.699183] Call Trace:
[ 1391.699188] dump_stack_lvl+0x57/0x7d
[ 1391.699198] check_preemption_disabled+0xc8/0xd0
[ 1391.699205] bnx2fc_recv_frame+0xbf9/0x1760 [bnx2fc]
[ 1391.699215] ? do_raw_spin_trylock+0xb5/0x180
[ 1391.699221] ? bnx2fc_npiv_create_vports.isra.0+0x4e0/0x4e0 [bnx2fc]
[ 1391.699229] ? bnx2fc_l2_rcv_thread+0xb7/0x3a0 [bnx2fc]
[ 1391.699240] bnx2fc_l2_rcv_thread+0x1af/0x3a0 [bnx2fc]
[ 1391.699250] ? bnx2fc_ulp_init+0xc0/0xc0 [bnx2fc]
[ 1391.699258] kthread+0x364/0x420
[ 1391.699263] ? _raw_spin_unlock_irq+0x24/0x50
[ 1391.699268] ? set_kthread_struct+0x100/0x100
[ 1391.699273] ret_from_fork+0x22/0x30
Restore the old get_cpu/put_cpu code with some modifications to reduce the
size of the critical section.
Link: https://lore.kernel.org/r/20220124145110.442335-1-jmeneghi@redhat.com
Fixes: d576a5e80cd0 ("bnx2fc: Improve stats update mechanism")
Tested-by: Guangwu Zhang <guazhang@redhat.com>
Acked-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: John Meneghini <jmeneghi@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -508,7 +508,8 @@ static int bnx2fc_l2_rcv_thread(void *ar
static void bnx2fc_recv_frame(struct sk_buff *skb)
{
- u32 fr_len;
+ u64 crc_err;
+ u32 fr_len, fr_crc;
struct fc_lport *lport;
struct fcoe_rcv_info *fr;
struct fc_stats *stats;
@@ -542,6 +543,11 @@ static void bnx2fc_recv_frame(struct sk_
skb_pull(skb, sizeof(struct fcoe_hdr));
fr_len = skb->len - sizeof(struct fcoe_crc_eof);
+ stats = per_cpu_ptr(lport->stats, get_cpu());
+ stats->RxFrames++;
+ stats->RxWords += fr_len / FCOE_WORD_TO_BYTE;
+ put_cpu();
+
fp = (struct fc_frame *)skb;
fc_frame_init(fp);
fr_dev(fp) = lport;
@@ -624,16 +630,15 @@ static void bnx2fc_recv_frame(struct sk_
return;
}
- stats = per_cpu_ptr(lport->stats, smp_processor_id());
- stats->RxFrames++;
- stats->RxWords += fr_len / FCOE_WORD_TO_BYTE;
+ fr_crc = le32_to_cpu(fr_crc(fp));
- if (le32_to_cpu(fr_crc(fp)) !=
- ~crc32(~0, skb->data, fr_len)) {
- if (stats->InvalidCRCCount < 5)
+ if (unlikely(fr_crc != ~crc32(~0, skb->data, fr_len))) {
+ stats = per_cpu_ptr(lport->stats, get_cpu());
+ crc_err = (stats->InvalidCRCCount++);
+ put_cpu();
+ if (crc_err < 5)
printk(KERN_WARNING PFX "dropping frame with "
"CRC error\n");
- stats->InvalidCRCCount++;
kfree_skb(skb);
return;
}
next prev parent reply other threads:[~2022-02-07 11:59 UTC|newest]
Thread overview: 112+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-07 11:05 [PATCH 5.15 000/110] 5.15.22-rc1 review Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 001/110] drm/i915: Disable DSB usage for now Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 002/110] selinux: fix double free of cond_list on error paths Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 003/110] audit: improve audit queue handling when "audit=1" on cmdline Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 004/110] ipc/sem: do not sleep with a spin lock held Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 005/110] spi: stm32-qspi: Update spi registering Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 006/110] ASoC: hdmi-codec: Fix OOB memory accesses Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 007/110] ASoC: ops: Reject out of bounds values in snd_soc_put_volsw() Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 008/110] ASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx() Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 009/110] ASoC: ops: Reject out of bounds values in snd_soc_put_xr_sx() Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 010/110] ALSA: usb-audio: Correct quirk for VF0770 Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 011/110] ALSA: hda: Fix UAF of leds class devs at unbinding Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 012/110] ALSA: hda: realtek: Fix race at concurrent COEF updates Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 013/110] ALSA: hda/realtek: Add quirk for ASUS GU603 Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 014/110] ALSA: hda/realtek: Add missing fixup-model entry for Gigabyte X570 ALC1220 quirks Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 015/110] ALSA: hda/realtek: Fix silent output on Gigabyte X570S Aorus Master (newer chipset) Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 016/110] ALSA: hda/realtek: Fix silent output on Gigabyte X570 Aorus Xtreme after reboot from Windows Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 017/110] btrfs: dont start transaction for scrub if the fs is mounted read-only Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 018/110] btrfs: fix deadlock between quota disable and qgroup rescan worker Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 019/110] btrfs: fix use-after-free after failure to create a snapshot Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 020/110] Revert "fs/9p: search open fids first" Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 021/110] drm/nouveau: fix off by one in BIOS boundary checking Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 022/110] drm/i915/adlp: Fix TypeC PHY-ready status readout Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 023/110] drm/amd/pm: correct the MGpuFanBoost support for Beige Goby Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 024/110] drm/amd/display: watermark latencies is not enough on DCN31 Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 025/110] drm/amd/display: Force link_rate as LINK_RATE_RBR2 for 2018 15" Apple Retina panels Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 026/110] nvme-fabrics: fix state check in nvmf_ctlr_matches_baseopts() Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 027/110] mm/debug_vm_pgtable: remove pte entry from the page table Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 028/110] mm/pgtable: define pte_index so that preprocessor could recognize it Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 029/110] mm/kmemleak: avoid scanning potential huge holes Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 030/110] block: bio-integrity: Advance seed correctly for larger interval sizes Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 031/110] dma-buf: heaps: Fix potential spectre v1 gadget Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 032/110] IB/hfi1: Fix AIP early init panic Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 033/110] Revert "fbcon: Disable accelerated scrolling" Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 034/110] fbcon: Add option to enable legacy hardware acceleration Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 035/110] mptcp: fix msk traversal in mptcp_nl_cmd_set_flags() Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 036/110] Revert "ASoC: mediatek: Check for error clk pointer" Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 037/110] KVM: arm64: Avoid consuming a stale esr value when SError occur Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 038/110] KVM: arm64: Stop handle_exit() from handling HVC twice when an SError occurs Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 039/110] RDMA/cma: Use correct address when leaving multicast group Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 040/110] RDMA/ucma: Protect mc during concurrent multicast leaves Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 041/110] RDMA/siw: Fix refcounting leak in siw_create_qp() Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 042/110] IB/rdmavt: Validate remote_addr during loopback atomic tests Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 043/110] RDMA/siw: Fix broken RDMA Read Fence/Resume logic Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 044/110] RDMA/mlx4: Dont continue event handler after memory allocation failure Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 045/110] ALSA: usb-audio: initialize variables that could ignore errors Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 046/110] ALSA: hda: Fix signedness of sscanf() arguments Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 047/110] ALSA: hda: Skip codec shutdown in case the codec is not registered Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 048/110] iommu/vt-d: Fix potential memory leak in intel_setup_irq_remapping() Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 049/110] iommu/amd: Fix loop timeout issue in iommu_ga_log_enable() Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 050/110] spi: bcm-qspi: check for valid cs before applying chip select Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 051/110] spi: mediatek: Avoid NULL pointer crash in interrupt Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 052/110] spi: meson-spicc: add IRQ check in meson_spicc_probe Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 053/110] spi: uniphier: fix reference count leak in uniphier_spi_probe() Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 054/110] IB/hfi1: Fix tstats alloc and dealloc Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 055/110] IB/cm: Release previously acquired reference counter in the cm_id_priv Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 056/110] net: ieee802154: hwsim: Ensure proper channel selection at probe time Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 057/110] net: ieee802154: mcr20a: Fix lifs/sifs periods Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 058/110] net: ieee802154: ca8210: Stop leaking skbs Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 059/110] netfilter: nft_reject_bridge: Fix for missing reply from prerouting Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 060/110] net: ieee802154: Return meaningful error codes from the netlink helpers Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 061/110] net/smc: Forward wakeup to smc socket waitqueue after fallback Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 062/110] net: stmmac: dwmac-visconti: No change to ETHER_CLOCK_SEL for unexpected speed request Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 063/110] net: stmmac: properly handle with runtime pm in stmmac_dvr_remove() Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 064/110] net: macsec: Fix offload support for NETDEV_UNREGISTER event Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 065/110] net: macsec: Verify that send_sci is on when setting Tx sci explicitly Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 066/110] net: stmmac: dump gmac4 DMA registers correctly Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 067/110] net: stmmac: ensure PTP time register reads are consistent Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 068/110] drm/kmb: Fix for build errors with Warray-bounds Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 069/110] drm/i915/overlay: Prevent divide by zero bugs in scaling Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 070/110] drm/amd: avoid suspend on dGPUs w/ s2idle support when runtime PM enabled Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 071/110] ASoC: fsl: Add missing error handling in pcm030_fabric_probe Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 072/110] ASoC: xilinx: xlnx_formatter_pcm: Make buffer bytes multiple of period bytes Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 073/110] ASoC: simple-card: fix probe failure on platform component Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 074/110] ASoC: cpcap: Check for NULL pointer after calling of_get_child_by_name Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 075/110] ASoC: max9759: fix underflow in speaker_gain_control_put() Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 076/110] ASoC: codecs: wcd938x: fix incorrect used of portid Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 077/110] ASoC: codecs: lpass-rx-macro: fix sidetone register offsets Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 078/110] ASoC: codecs: wcd938x: fix return value of mixer put function Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 079/110] pinctrl: sunxi: Fix H616 I2S3 pin data Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 080/110] pinctrl: intel: Fix a glitch when updating IRQ flags on a preconfigured line Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 081/110] pinctrl: intel: fix unexpected interrupt Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 082/110] pinctrl: bcm2835: Fix a few error paths Greg Kroah-Hartman
2022-02-07 11:06 ` Greg Kroah-Hartman [this message]
2022-02-07 11:06 ` [PATCH 5.15 084/110] nfsd: nfsd4_setclientid_confirm mistakenly expires confirmed client Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 085/110] gve: fix the wrong AdminQ buffer queue index check Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 086/110] bpf: Use VM_MAP instead of VM_ALLOC for ringbuf Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 087/110] selftests/exec: Remove pipe from TEST_GEN_FILES Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 088/110] selftests: futex: Use variable MAKE instead of make Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 089/110] tools/resolve_btfids: Do not print any commands when building silently Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 090/110] e1000e: Separate ADP board type from TGP Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 091/110] rtc: cmos: Evaluate century appropriate Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 092/110] kvm/arm64: rework guest entry logic Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 093/110] perf: Copy perf_event_attr::sig_data on modification Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 094/110] perf stat: Fix display of grouped aliased events Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 095/110] perf/x86/intel/pt: Fix crash with stop filters in single-range mode Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 096/110] x86/perf: Default set FREEZE_ON_SMI for all Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 097/110] EDAC/altera: Fix deferred probing Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 098/110] EDAC/xgene: " Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 099/110] ext4: prevent used blocks from being allocated during fast commit replay Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 100/110] ext4: modify the logic of ext4_mb_new_blocks_simple Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 101/110] ext4: fix error handling in ext4_restore_inline_data() Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 102/110] ext4: fix error handling in ext4_fc_record_modified_inode() Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 103/110] ext4: fix incorrect type issue during replay_del_range Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 104/110] net: dsa: mt7530: make NET_DSA_MT7530 select MEDIATEK_GE_PHY Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 105/110] cgroup/cpuset: Fix "suspicious RCU usage" lockdep warning Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 106/110] tools include UAPI: Sync sound/asound.h copy with the kernel sources Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 107/110] gpio: idt3243x: Fix an ignored error return from platform_get_irq() Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 108/110] gpio: mpc8xxx: " Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 109/110] selftests: nft_concat_range: add test for reload with no element add/del Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 110/110] selftests: netfilter: check stateless nat udp checksum fixup Greg Kroah-Hartman
2022-02-07 12:29 ` [PATCH 5.15 000/110] 5.15.22-rc1 review Naresh Kamboju
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220207103805.208752206@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=guazhang@redhat.com \
--cc=jmeneghi@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=skashyap@marvell.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).