Skip to content

Commit 91f9181

Browse files
michichanguy11
authored andcommitted
ice: fix theoretical out-of-bounds access in ethtool link modes
To map phy types reported by the hardware to ethtool link mode bits, ice uses two lookup tables (phy_type_low_lkup, phy_type_high_lkup). The "low" table has 64 elements to cover every possible bit the hardware may report, but the "high" table has only 13. If the hardware reports a higher bit in phy_types_high, the driver would access memory beyond the lookup table's end. Instead of iterating through all 64 bits of phy_types_{low,high}, use the sizes of the respective lookup tables. Fixes: 9136e1f ("ice: refactor PHY type to ethtool link mode") Signed-off-by: Michal Schmidt <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Reviewed-by: Simon Horman <[email protected]> Tested-by: Pucha Himasekhar Reddy <[email protected]> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <[email protected]>
1 parent 2513974 commit 91f9181

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/net/ethernet/intel/ice/ice_ethtool.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,14 +1850,14 @@ ice_phy_type_to_ethtool(struct net_device *netdev,
18501850
linkmode_zero(ks->link_modes.supported);
18511851
linkmode_zero(ks->link_modes.advertising);
18521852

1853-
for (i = 0; i < BITS_PER_TYPE(u64); i++) {
1853+
for (i = 0; i < ARRAY_SIZE(phy_type_low_lkup); i++) {
18541854
if (phy_types_low & BIT_ULL(i))
18551855
ice_linkmode_set_bit(&phy_type_low_lkup[i], ks,
18561856
req_speeds, advert_phy_type_lo,
18571857
i);
18581858
}
18591859

1860-
for (i = 0; i < BITS_PER_TYPE(u64); i++) {
1860+
for (i = 0; i < ARRAY_SIZE(phy_type_high_lkup); i++) {
18611861
if (phy_types_high & BIT_ULL(i))
18621862
ice_linkmode_set_bit(&phy_type_high_lkup[i], ks,
18631863
req_speeds, advert_phy_type_hi,

0 commit comments

Comments
 (0)