net/bonding: fix adding itself as its slave
authorChengchang Tang <tangchengchang@huawei.com>
Thu, 15 Apr 2021 07:09:54 +0000 (15:09 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 20 Apr 2021 01:36:05 +0000 (03:36 +0200)
commit324d6577ba678c00673427df681bf2debec1db8d
tree140e1107dc4ba680077d850ed6e5b92183798256
parent687833fffad21fee54ad76d32c536eb5ec4f59b1
net/bonding: fix adding itself as its slave

Adding the bond device as its own slave should be forbidden. This
will cause a recursive endless loop in many subsequent operations,
and eventually lead to coredump.

This problem was found in testpmd, the related logs are as follows:
testpmd> create bonded device 1 0
Created new bonded device net_bonding_testpmd_0 on (port 4).
testpmd> add bonding slave 4 4
Segmentation fault (core dumped)

The call stack is as follows:
0x000000000064eb90 in rte_eth_dev_info_get ()
0x00000000006df4b4 in bond_ethdev_info ()
0x000000000064eb90 in rte_eth_dev_info_get ()
0x00000000006df4b4 in bond_ethdev_info ()
0x000000000064eb90 in rte_eth_dev_info_get ()
0x0000000000564e58 in eth_dev_info_get_print_err ()
0x000000000055e8a4 in init_port_config ()
0x000000000052730c in cmd_add_bonding_slave_parsed ()
0x0000000000646f60 in cmdline_parse ()
0x0000000000645e08 in cmdline_valid_buffer ()
0x000000000064956c in rdline_char_in ()
0x0000000000645ee0 in cmdline_in ()
0x00000000006460a4 in cmdline_interact ()
0x0000000000531904 in prompt ()
0x000000000051cca8 in main ()

Fixes: 2efb58cbab6e ("bond: new link bonding library")
Cc: stable@dpdk.org
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
drivers/net/bonding/eth_bond_private.h
drivers/net/bonding/rte_eth_bond_api.c