linux-stable/drivers/net/ethernet/intel/ice
Anatolii Gerasymenko a632b2a4c9 ice: ethtool: Prohibit improper channel config for DCB
Do not allow setting less channels, than Traffic Classes there are
via ethtool. There must be at least one channel per Traffic Class.

If you set less channels, than Traffic Classes there are, then during
ice_vsi_rebuild there would be allocated only the requested amount
of tx/rx rings in ice_vsi_alloc_arrays. But later in ice_vsi_setup_q_map
there would be requested at least one channel per Traffic Class. This
results in setting num_rxq > alloc_rxq and num_txq > alloc_txq.
Later, there would be a NULL pointer dereference in
ice_vsi_map_rings_to_vectors, because we go beyond of rx_rings or
tx_rings arrays.

Change ice_set_channels() to return error if you try to allocate less
channels, than Traffic Classes there are.
Change ice_vsi_setup_q_map() and ice_vsi_setup_q_map_mqprio() to return
status code instead of void.
Add error handling for ice_vsi_setup_q_map() and
ice_vsi_setup_q_map_mqprio() in ice_vsi_init() and ice_vsi_cfg_tc().

[53753.889983] INFO: Flow control is disabled for this traffic class (0) on this vsi.
[53763.984862] BUG: unable to handle kernel NULL pointer dereference at 0000000000000028
[53763.992915] PGD 14b45f5067 P4D 0
[53763.996444] Oops: 0002 [#1] SMP NOPTI
[53764.000312] CPU: 12 PID: 30661 Comm: ethtool Kdump: loaded Tainted: GOE    --------- -  - 4.18.0-240.el8.x86_64 #1
[53764.011825] Hardware name: Intel Corporation WilsonCity/WilsonCity, BIOS WLYDCRB1.SYS.0020.P21.2012150710 12/15/2020
[53764.022584] RIP: 0010:ice_vsi_map_rings_to_vectors+0x7e/0x120 [ice]
[53764.029089] Code: 41 0d 0f b7 b7 12 05 00 00 0f b6 d0 44 29 de 44 0f b7 c6 44 01 c2 41 39 d0 7d 2d 4c 8b 47 28 44 0f b7 ce 83 c6 01 4f 8b 04 c8 <49> 89 48 28 4                           c 8b 89 b8 01 00 00 4d 89 08 4c 89 81 b8 01 00 00 44
[53764.048379] RSP: 0018:ff550dd88ea47b20 EFLAGS: 00010206
[53764.053884] RAX: 0000000000000002 RBX: 0000000000000004 RCX: ff385ea42fa4a018
[53764.061301] RDX: 0000000000000006 RSI: 0000000000000005 RDI: ff385e9baeedd018
[53764.068717] RBP: 0000000000000010 R08: 0000000000000000 R09: 0000000000000004
[53764.076133] R10: 0000000000000002 R11: 0000000000000004 R12: 0000000000000000
[53764.083553] R13: 0000000000000000 R14: ff385e658fdd9000 R15: ff385e9baeedd018
[53764.090976] FS:  000014872c5b5740(0000) GS:ff385e847f100000(0000) knlGS:0000000000000000
[53764.099362] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[53764.105409] CR2: 0000000000000028 CR3: 0000000a820fa002 CR4: 0000000000761ee0
[53764.112851] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[53764.120301] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[53764.127747] PKRU: 55555554
[53764.130781] Call Trace:
[53764.133564]  ice_vsi_rebuild+0x611/0x870 [ice]
[53764.138341]  ice_vsi_recfg_qs+0x94/0x100 [ice]
[53764.143116]  ice_set_channels+0x1a8/0x3e0 [ice]
[53764.147975]  ethtool_set_channels+0x14e/0x240
[53764.152667]  dev_ethtool+0xd74/0x2a10
[53764.156665]  ? __mod_lruvec_state+0x44/0x110
[53764.161280]  ? __mod_lruvec_state+0x44/0x110
[53764.165893]  ? page_add_file_rmap+0x15/0x170
[53764.170518]  ? inet_ioctl+0xd1/0x220
[53764.174445]  ? netdev_run_todo+0x5e/0x290
[53764.178808]  dev_ioctl+0xb5/0x550
[53764.182485]  sock_do_ioctl+0xa0/0x140
[53764.186512]  sock_ioctl+0x1a8/0x300
[53764.190367]  ? selinux_file_ioctl+0x161/0x200
[53764.195090]  do_vfs_ioctl+0xa4/0x640
[53764.199035]  ksys_ioctl+0x60/0x90
[53764.202722]  __x64_sys_ioctl+0x16/0x20
[53764.206845]  do_syscall_64+0x5b/0x1a0
[53764.210887]  entry_SYSCALL_64_after_hwframe+0x65/0xca

Fixes: 87324e747f ("ice: Implement ethtool ops for channels")
Signed-off-by: Anatolii Gerasymenko <anatolii.gerasymenko@intel.com>
Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
2022-06-21 15:20:24 -07:00
..
Makefile ice: fix access-beyond-end in the switch code 2022-06-02 12:41:10 +02:00
ice.h Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-05-12 16:15:30 -07:00
ice_adminq_cmd.h ice: fix access-beyond-end in the switch code 2022-06-02 12:41:10 +02:00
ice_arfs.c ice: arfs: fix use-after-free when freeing @rx_cpu_rmap 2022-04-08 09:08:36 -07:00
ice_arfs.h ice: remove circular header dependencies on ice.h 2022-03-14 17:22:58 -07:00
ice_base.c ice: rename ice_virtchnl_pf.c to ice_sriov.c 2022-03-14 17:22:58 -07:00
ice_base.h
ice_cgu_regs.h ice: ensure the hardware Clock Generation Unit is configured 2021-12-21 09:11:40 -08:00
ice_common.c ice: add TTY for GNSS module for E810T device 2022-03-03 14:11:00 +00:00
ice_common.h ice: remove circular header dependencies on ice.h 2022-03-14 17:22:58 -07:00
ice_controlq.c ice: Cleanup after ice_status removal 2021-12-14 10:19:13 -08:00
ice_controlq.h
ice_dcb.c ice: Cleanup after ice_status removal 2021-12-14 10:19:13 -08:00
ice_dcb.h ice: remove circular header dependencies on ice.h 2022-03-14 17:22:58 -07:00
ice_dcb_lib.c ice: Add hot path support for 802.1Q and 802.1ad VLAN offloads 2022-02-09 09:24:45 -08:00
ice_dcb_lib.h
ice_dcb_nl.c
ice_dcb_nl.h
ice_devids.h
ice_devlink.c ice: always check VF VSI pointer values 2022-05-05 11:28:36 -07:00
ice_devlink.h
ice_eswitch.c ice: fix crash in switchdev mode 2022-04-14 08:19:54 -07:00
ice_eswitch.h ice: allow creating VFs for !CONFIG_NET_SWITCHDEV 2022-04-14 08:19:54 -07:00
ice_ethtool.c ice: ethtool: Prohibit improper channel config for DCB 2022-06-21 15:20:24 -07:00
ice_ethtool_fdir.c ice: Add flow director support for channel mode 2021-12-30 13:16:07 +00:00
ice_fdir.c ice: Cleanup after ice_status removal 2021-12-14 10:19:13 -08:00
ice_fdir.h ice: Add flow director support for channel mode 2021-12-30 13:16:07 +00:00
ice_flex_pipe.c ice: remove circular header dependencies on ice.h 2022-03-14 17:22:58 -07:00
ice_flex_pipe.h ice: Fix FV offset searching 2022-03-11 08:28:27 -08:00
ice_flex_type.h ice: Support GTP-U and GTP-C offload in switchdev 2022-03-11 08:28:28 -08:00
ice_flow.c ice: remove circular header dependencies on ice.h 2022-03-14 17:22:58 -07:00
ice_flow.h ice: remove circular header dependencies on ice.h 2022-03-14 17:22:58 -07:00
ice_fltr.c ice: Fix broken IFF_ALLMULTI handling 2022-04-01 12:01:38 +01:00
ice_fltr.h ice: Introduce ice_vlan struct 2022-02-09 09:24:45 -08:00
ice_fw_update.c ice: support immediate firmware activation via devlink reload 2021-12-15 08:40:38 -08:00
ice_fw_update.h ice: support immediate firmware activation via devlink reload 2021-12-15 08:40:38 -08:00
ice_gnss.c ice: use min_t() to make code cleaner in ice_gnss 2022-05-05 11:28:35 -07:00
ice_gnss.h ice: add TTY for GNSS module for E810T device 2022-03-03 14:11:00 +00:00
ice_hw_autogen.h ice: support crosstimestamping on E822 devices if supported 2021-12-21 09:11:40 -08:00
ice_idc.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-05-12 16:15:30 -07:00
ice_idc_int.h ice: remove circular header dependencies on ice.h 2022-03-14 17:22:58 -07:00
ice_lag.c ice: Fix KASAN error in LAG NETDEV_UNREGISTER handler 2022-02-10 08:47:26 -08:00
ice_lag.h
ice_lan_tx_rx.h Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-02-10 17:29:56 -08:00
ice_lib.c ice: ethtool: Prohibit improper channel config for DCB 2022-06-21 15:20:24 -07:00
ice_lib.h ice: store VF pointer instead of VF ID 2022-03-03 08:46:47 -08:00
ice_main.c ice: Sync VLAN filtering features for DVM 2022-06-14 09:38:57 -07:00
ice_nvm.c ice: Fix memory leak in ice_get_orom_civd_data() 2022-04-14 08:31:01 -07:00
ice_nvm.h ice: support immediate firmware activation via devlink reload 2021-12-15 08:40:38 -08:00
ice_osdep.h ice: remove circular header dependencies on ice.h 2022-03-14 17:22:58 -07:00
ice_pf_vsi_vlan_ops.c ice: Support configuring the device to Double VLAN Mode 2022-02-09 09:24:45 -08:00
ice_pf_vsi_vlan_ops.h ice: Add outer_vlan_ops and VSI specific VLAN ops implementations 2022-02-09 09:24:45 -08:00
ice_protocol_type.h ice: Support GTP-U and GTP-C offload in switchdev 2022-03-11 08:28:28 -08:00
ice_ptp.c ice: Fix PTP TX timestamp offset calculation 2022-06-14 09:35:57 -07:00
ice_ptp.h ice: Fix PTP TX timestamp offset calculation 2022-06-14 09:35:57 -07:00
ice_ptp_consts.h ice: ensure the hardware Clock Generation Unit is configured 2021-12-21 09:11:40 -08:00
ice_ptp_hw.c ice: add TTY for GNSS module for E810T device 2022-03-03 14:11:00 +00:00
ice_ptp_hw.h ice: add TTY for GNSS module for E810T device 2022-03-03 14:11:00 +00:00
ice_repr.c ice: link representors to PCI device 2022-05-06 09:43:01 -07:00
ice_repr.h ice: remove circular header dependencies on ice.h 2022-03-14 17:22:58 -07:00
ice_sbq_cmd.h
ice_sched.c ice: Remove unnecessary casts 2021-12-14 10:19:14 -08:00
ice_sched.h ice: Cleanup after ice_status removal 2021-12-14 10:19:13 -08:00
ice_sriov.c ice: always check VF VSI pointer values 2022-05-05 11:28:36 -07:00
ice_sriov.h ice: introduce ice_virtchnl.c and ice_virtchnl.h 2022-03-15 13:23:10 -07:00
ice_switch.c ice: fix access-beyond-end in the switch code 2022-06-02 12:41:10 +02:00
ice_switch.h ice: fix access-beyond-end in the switch code 2022-06-02 12:41:10 +02:00
ice_tc_lib.c ice: Fix switchdev rules book keeping 2022-06-21 13:09:03 -07:00
ice_tc_lib.h ice: Support GTP-U and GTP-C offload in switchdev 2022-03-11 08:28:28 -08:00
ice_trace.h ice: add trace events for tx timestamps 2022-03-16 10:38:15 -07:00
ice_txrx.c ice: Add mpls+tso support 2022-04-12 11:05:09 -07:00
ice_txrx.h Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-05-19 11:23:59 -07:00
ice_txrx_lib.c Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue 2022-02-10 11:00:13 +00:00
ice_txrx_lib.h ice: Add hot path support for 802.1Q and 802.1ad VLAN offloads 2022-02-09 09:24:45 -08:00
ice_type.h ice: remove circular header dependencies on ice.h 2022-03-14 17:22:58 -07:00
ice_vf_lib.c ice: Fix memory corruption in VF driver 2022-06-14 09:38:57 -07:00
ice_vf_lib.h ice: remove period on argument description in ice_for_each_vf 2022-05-05 11:28:36 -07:00
ice_vf_lib_private.h ice: remove PF pointer from ice_check_vf_init 2022-03-15 13:23:14 -07:00
ice_vf_mbx.c ice: rename ice_sriov.c to ice_vf_mbx.c 2022-03-14 17:22:58 -07:00
ice_vf_mbx.h ice: rename ice_sriov.c to ice_vf_mbx.c 2022-03-14 17:22:58 -07:00
ice_vf_vsi_vlan_ops.c ice: rename ice_virtchnl_pf.c to ice_sriov.c 2022-03-14 17:22:58 -07:00
ice_vf_vsi_vlan_ops.h ice: Add support for VIRTCHNL_VF_OFFLOAD_VLAN_V2 2022-02-09 09:24:45 -08:00
ice_virtchnl.c ice: Fix queue config fail handling 2022-06-14 09:38:57 -07:00
ice_virtchnl.h ice: introduce ice_virtchnl.c and ice_virtchnl.h 2022-03-15 13:23:10 -07:00
ice_virtchnl_allowlist.c ice: Add support for VIRTCHNL_VF_OFFLOAD_VLAN_V2 2022-02-09 09:24:45 -08:00
ice_virtchnl_allowlist.h
ice_virtchnl_fdir.c ice: always check VF VSI pointer values 2022-05-05 11:28:36 -07:00
ice_virtchnl_fdir.h ice: introduce ice_vf_lib.c, ice_vf_lib.h, and ice_vf_lib_private.h 2022-03-15 13:22:13 -07:00
ice_vlan.h ice: Use the proto argument for VLAN ops 2022-02-09 09:24:45 -08:00
ice_vlan_mode.c ice: Support configuring the device to Double VLAN Mode 2022-02-09 09:24:45 -08:00
ice_vlan_mode.h ice: Support configuring the device to Double VLAN Mode 2022-02-09 09:24:45 -08:00
ice_vsi_vlan_lib.c ice: Support configuring the device to Double VLAN Mode 2022-02-09 09:24:45 -08:00
ice_vsi_vlan_lib.h ice: Add outer_vlan_ops and VSI specific VLAN ops implementations 2022-02-09 09:24:45 -08:00
ice_vsi_vlan_ops.c ice: Add outer_vlan_ops and VSI specific VLAN ops implementations 2022-02-09 09:24:45 -08:00
ice_vsi_vlan_ops.h ice: Support configuring the device to Double VLAN Mode 2022-02-09 09:24:45 -08:00
ice_xsk.c Merge https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next 2022-04-27 17:09:32 -07:00
ice_xsk.h ice: remove circular header dependencies on ice.h 2022-03-14 17:22:58 -07:00