Skip to content

Commit 412b65d

Browse files
Timmy Lidavem330
Timmy Li
authored andcommitted
net: hns: fix ethtool_get_strings overflow in hns driver
hns_get_sset_count() returns HNS_NET_STATS_CNT and the data space allocated is not enough for ethtool_get_strings(), which will cause random memory corruption. When SLAB and DEBUG_SLAB are both enabled, memory corruptions like the the following can be observed without this patch: [ 43.115200] Slab corruption (Not tainted): Acpi-ParseExt start=ffff801fb0b69030, len=80 [ 43.115206] Redzone: 0x9f911029d006462/0x5f78745f31657070. [ 43.115208] Last user: [<5f7272655f746b70>](0x5f7272655f746b70) [ 43.115214] 010: 70 70 65 31 5f 74 78 5f 70 6b 74 00 6b 6b 6b 6b ppe1_tx_pkt.kkkk [ 43.115217] 030: 70 70 65 31 5f 74 78 5f 70 6b 74 5f 6f 6b 00 6b ppe1_tx_pkt_ok.k [ 43.115218] Next obj: start=ffff801fb0b69098, len=80 [ 43.115220] Redzone: 0x706d655f6f666966/0x9f911029d74e35b. [ 43.115229] Last user: [<ffff0000084b11b0>](acpi_os_release_object+0x28/0x38) [ 43.115231] 000: 74 79 00 6b 6b 6b 6b 6b 70 70 65 31 5f 74 78 5f ty.kkkkkppe1_tx_ [ 43.115232] 010: 70 6b 74 5f 65 72 72 5f 63 73 75 6d 5f 66 61 69 pkt_err_csum_fai Signed-off-by: Timmy Li <lixiaoping3@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a9f11f9 commit 412b65d

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

Diff for: drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ static void hns_gmac_get_strings(u32 stringset, u8 *data)
666666

667667
static int hns_gmac_get_sset_count(int stringset)
668668
{
669-
if (stringset == ETH_SS_STATS)
669+
if (stringset == ETH_SS_STATS || stringset == ETH_SS_PRIV_FLAGS)
670670
return ARRAY_SIZE(g_gmac_stats_string);
671671

672672
return 0;

Diff for: drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ void hns_ppe_update_stats(struct hns_ppe_cb *ppe_cb)
422422

423423
int hns_ppe_get_sset_count(int stringset)
424424
{
425-
if (stringset == ETH_SS_STATS)
425+
if (stringset == ETH_SS_STATS || stringset == ETH_SS_PRIV_FLAGS)
426426
return ETH_PPE_STATIC_NUM;
427427
return 0;
428428
}

Diff for: drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ void hns_rcb_get_stats(struct hnae_queue *queue, u64 *data)
876876
*/
877877
int hns_rcb_get_ring_sset_count(int stringset)
878878
{
879-
if (stringset == ETH_SS_STATS)
879+
if (stringset == ETH_SS_STATS || stringset == ETH_SS_PRIV_FLAGS)
880880
return HNS_RING_STATIC_REG_NUM;
881881

882882
return 0;

Diff for: drivers/net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ static void hns_xgmac_get_strings(u32 stringset, u8 *data)
781781
*/
782782
static int hns_xgmac_get_sset_count(int stringset)
783783
{
784-
if (stringset == ETH_SS_STATS)
784+
if (stringset == ETH_SS_STATS || stringset == ETH_SS_PRIV_FLAGS)
785785
return ARRAY_SIZE(g_xgmac_stats_string);
786786

787787
return 0;

0 commit comments

Comments
 (0)