Skip to content

Commit c35b57c

Browse files
vladimirolteankuba-moo
authored andcommitted
net: switchdev: zero-initialize struct switchdev_notifier_fdb_info emitted by drivers towards the bridge
The blamed commit added a new field to struct switchdev_notifier_fdb_info, but did not make sure that all call paths set it to something valid. For example, a switchdev driver may emit a SWITCHDEV_FDB_ADD_TO_BRIDGE notifier, and since the 'is_local' flag is not set, it contains junk from the stack, so the bridge might interpret those notifications as being for local FDB entries when that was not intended. To avoid that now and in the future, zero-initialize all switchdev_notifier_fdb_info structures created by drivers such that all newly added fields to not need to touch drivers again. Fixes: 2c4eca3 ("net: bridge: switchdev: include local flag in FDB notifications") Reported-by: Ido Schimmel <[email protected]> Signed-off-by: Vladimir Oltean <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Tested-by: Ido Schimmel <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Reviewed-by: Karsten Graul <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 45a6878 commit c35b57c

File tree

11 files changed

+14
-14
lines changed

11 files changed

+14
-14
lines changed

drivers/net/ethernet/marvell/prestera/prestera_switchdev.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ static void
748748
prestera_fdb_offload_notify(struct prestera_port *port,
749749
struct switchdev_notifier_fdb_info *info)
750750
{
751-
struct switchdev_notifier_fdb_info send_info;
751+
struct switchdev_notifier_fdb_info send_info = {};
752752

753753
send_info.addr = info->addr;
754754
send_info.vid = info->vid;
@@ -1123,7 +1123,7 @@ static int prestera_switchdev_blk_event(struct notifier_block *unused,
11231123
static void prestera_fdb_event(struct prestera_switch *sw,
11241124
struct prestera_event *evt, void *arg)
11251125
{
1126-
struct switchdev_notifier_fdb_info info;
1126+
struct switchdev_notifier_fdb_info info = {};
11271127
struct net_device *dev = NULL;
11281128
struct prestera_port *port;
11291129
struct prestera_lag *lag;

drivers/net/ethernet/mellanox/mlx5/core/esw/bridge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static void
6969
mlx5_esw_bridge_fdb_offload_notify(struct net_device *dev, const unsigned char *addr, u16 vid,
7070
unsigned long val)
7171
{
72-
struct switchdev_notifier_fdb_info send_info;
72+
struct switchdev_notifier_fdb_info send_info = {};
7373

7474
send_info.addr = addr;
7575
send_info.vid = vid;

drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9079,7 +9079,7 @@ mlxsw_sp_rif_fid_fid_get(struct mlxsw_sp_rif *rif,
90799079

90809080
static void mlxsw_sp_rif_fid_fdb_del(struct mlxsw_sp_rif *rif, const char *mac)
90819081
{
9082-
struct switchdev_notifier_fdb_info info;
9082+
struct switchdev_notifier_fdb_info info = {};
90839083
struct net_device *dev;
90849084

90859085
dev = br_fdb_find_port(rif->dev, mac, 0);
@@ -9127,8 +9127,8 @@ mlxsw_sp_rif_vlan_fid_get(struct mlxsw_sp_rif *rif,
91279127

91289128
static void mlxsw_sp_rif_vlan_fdb_del(struct mlxsw_sp_rif *rif, const char *mac)
91299129
{
9130+
struct switchdev_notifier_fdb_info info = {};
91309131
u16 vid = mlxsw_sp_fid_8021q_vid(rif->fid);
9131-
struct switchdev_notifier_fdb_info info;
91329132
struct net_device *br_dev;
91339133
struct net_device *dev;
91349134

drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2508,7 +2508,7 @@ mlxsw_sp_fdb_call_notifiers(enum switchdev_notifier_type type,
25082508
const char *mac, u16 vid,
25092509
struct net_device *dev, bool offloaded)
25102510
{
2511-
struct switchdev_notifier_fdb_info info;
2511+
struct switchdev_notifier_fdb_info info = {};
25122512

25132513
info.addr = mac;
25142514
info.vid = vid;

drivers/net/ethernet/microchip/sparx5/sparx5_mactable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ static void sparx5_fdb_call_notifiers(enum switchdev_notifier_type type,
277277
const char *mac, u16 vid,
278278
struct net_device *dev, bool offloaded)
279279
{
280-
struct switchdev_notifier_fdb_info info;
280+
struct switchdev_notifier_fdb_info info = {};
281281

282282
info.addr = mac;
283283
info.vid = vid;

drivers/net/ethernet/rocker/rocker_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2715,7 +2715,7 @@ static void
27152715
rocker_fdb_offload_notify(struct rocker_port *rocker_port,
27162716
struct switchdev_notifier_fdb_info *recv_info)
27172717
{
2718-
struct switchdev_notifier_fdb_info info;
2718+
struct switchdev_notifier_fdb_info info = {};
27192719

27202720
info.addr = recv_info->addr;
27212721
info.vid = recv_info->vid;

drivers/net/ethernet/rocker/rocker_ofdpa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1822,7 +1822,7 @@ static void ofdpa_port_fdb_learn_work(struct work_struct *work)
18221822
container_of(work, struct ofdpa_fdb_learn_work, work);
18231823
bool removing = (lw->flags & OFDPA_OP_FLAG_REMOVE);
18241824
bool learned = (lw->flags & OFDPA_OP_FLAG_LEARNED);
1825-
struct switchdev_notifier_fdb_info info;
1825+
struct switchdev_notifier_fdb_info info = {};
18261826

18271827
info.addr = lw->addr;
18281828
info.vid = lw->vid;

drivers/net/ethernet/ti/am65-cpsw-switchdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ static int am65_cpsw_port_obj_del(struct net_device *ndev, const void *ctx,
358358
static void am65_cpsw_fdb_offload_notify(struct net_device *ndev,
359359
struct switchdev_notifier_fdb_info *rcv)
360360
{
361-
struct switchdev_notifier_fdb_info info;
361+
struct switchdev_notifier_fdb_info info = {};
362362

363363
info.addr = rcv->addr;
364364
info.vid = rcv->vid;

drivers/net/ethernet/ti/cpsw_switchdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ static int cpsw_port_obj_del(struct net_device *ndev, const void *ctx,
368368
static void cpsw_fdb_offload_notify(struct net_device *ndev,
369369
struct switchdev_notifier_fdb_info *rcv)
370370
{
371-
struct switchdev_notifier_fdb_info info;
371+
struct switchdev_notifier_fdb_info info = {};
372372

373373
info.addr = rcv->addr;
374374
info.vid = rcv->vid;

drivers/s390/net/qeth_l2_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ static void qeth_l2_set_pnso_mode(struct qeth_card *card,
279279

280280
static void qeth_l2_dev2br_fdb_flush(struct qeth_card *card)
281281
{
282-
struct switchdev_notifier_fdb_info info;
282+
struct switchdev_notifier_fdb_info info = {};
283283

284284
QETH_CARD_TEXT(card, 2, "fdbflush");
285285

@@ -679,7 +679,7 @@ static void qeth_l2_dev2br_fdb_notify(struct qeth_card *card, u8 code,
679679
struct net_if_token *token,
680680
struct mac_addr_lnid *addr_lnid)
681681
{
682-
struct switchdev_notifier_fdb_info info;
682+
struct switchdev_notifier_fdb_info info = {};
683683
u8 ntfy_mac[ETH_ALEN];
684684

685685
ether_addr_copy(ntfy_mac, addr_lnid->mac);

0 commit comments

Comments
 (0)