Skip to content

Commit adb4307

Browse files
liuhangbinNipaLocal
authored andcommitted
bonding: fix NULL pointer dereference in actor_port_prio setting
Liang reported an issue where setting a slave’s actor_port_prio to predefined values such as 0, 255, or 65535 would cause a system crash. The problem occurs because in bond_opt_parse(), when the provided value matches a predefined table entry, the function returns that table entry, which does not contain slave information. Later, in bond_option_actor_port_prio_set(), calling bond_slave_get_rtnl() leads to a NULL pointer dereference. Since actor_port_prio is defined as a u16 and initialized to the default value of 255 in ad_initialize_port(), there is no need for the bond_actor_port_prio_tbl. Using the BOND_OPTFLAG_RAWVAL flag is sufficient. Fixes: 6b6dc81 ("bonding: add support for per-port LACP actor priority") Reported-by: Liang Li <[email protected]> Signed-off-by: Hangbin Liu <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent ffb0bea commit adb4307

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

drivers/net/bonding/bond_options.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,6 @@ static const struct bond_opt_value bond_ad_actor_sys_prio_tbl[] = {
225225
{ NULL, -1, 0},
226226
};
227227

228-
static const struct bond_opt_value bond_actor_port_prio_tbl[] = {
229-
{ "minval", 0, BOND_VALFLAG_MIN},
230-
{ "maxval", 65535, BOND_VALFLAG_MAX},
231-
{ "default", 255, BOND_VALFLAG_DEFAULT},
232-
{ NULL, -1, 0},
233-
};
234-
235228
static const struct bond_opt_value bond_ad_user_port_key_tbl[] = {
236229
{ "minval", 0, BOND_VALFLAG_MIN | BOND_VALFLAG_DEFAULT},
237230
{ "maxval", 1023, BOND_VALFLAG_MAX},
@@ -497,7 +490,7 @@ static const struct bond_option bond_opts[BOND_OPT_LAST] = {
497490
.id = BOND_OPT_ACTOR_PORT_PRIO,
498491
.name = "actor_port_prio",
499492
.unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)),
500-
.values = bond_actor_port_prio_tbl,
493+
.flags = BOND_OPTFLAG_RAWVAL,
501494
.set = bond_option_actor_port_prio_set,
502495
},
503496
[BOND_OPT_AD_ACTOR_SYSTEM] = {

0 commit comments

Comments
 (0)