Skip to content

Commit 9949e2e

Browse files
liuhangbindavem330
authored andcommitted
bonding: fix send_peer_notif overflow
Bonding send_peer_notif was defined as u8. Since commit 07a4dde ("bonding: add an option to specify a delay between peer notifications"). the bond->send_peer_notif will be num_peer_notif multiplied by peer_notif_delay, which is u8 * u32. This would cause the send_peer_notif overflow easily. e.g. ip link add bond0 type bond mode 1 miimon 100 num_grat_arp 30 peer_notify_delay 1000 To fix the overflow, let's set the send_peer_notif to u32 and limit peer_notif_delay to 300s. Reported-by: Liang Li <[email protected]> Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2090053 Fixes: 07a4dde ("bonding: add an option to specify a delay between peer notifications") Signed-off-by: Hangbin Liu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7c83e28 commit 9949e2e

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

drivers/net/bonding/bond_netlink.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ static int bond_fill_slave_info(struct sk_buff *skb,
8484
return -EMSGSIZE;
8585
}
8686

87+
/* Limit the max delay range to 300s */
88+
static struct netlink_range_validation delay_range = {
89+
.max = 300000,
90+
};
91+
8792
static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = {
8893
[IFLA_BOND_MODE] = { .type = NLA_U8 },
8994
[IFLA_BOND_ACTIVE_SLAVE] = { .type = NLA_U32 },
@@ -114,7 +119,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = {
114119
[IFLA_BOND_AD_ACTOR_SYSTEM] = { .type = NLA_BINARY,
115120
.len = ETH_ALEN },
116121
[IFLA_BOND_TLB_DYNAMIC_LB] = { .type = NLA_U8 },
117-
[IFLA_BOND_PEER_NOTIF_DELAY] = { .type = NLA_U32 },
122+
[IFLA_BOND_PEER_NOTIF_DELAY] = NLA_POLICY_FULL_RANGE(NLA_U32, &delay_range),
118123
[IFLA_BOND_MISSED_MAX] = { .type = NLA_U8 },
119124
[IFLA_BOND_NS_IP6_TARGET] = { .type = NLA_NESTED },
120125
};

drivers/net/bonding/bond_options.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ static const struct bond_opt_value bond_num_peer_notif_tbl[] = {
169169
{ NULL, -1, 0}
170170
};
171171

172+
static const struct bond_opt_value bond_peer_notif_delay_tbl[] = {
173+
{ "off", 0, 0},
174+
{ "maxval", 300000, BOND_VALFLAG_MAX},
175+
{ NULL, -1, 0}
176+
};
177+
172178
static const struct bond_opt_value bond_primary_reselect_tbl[] = {
173179
{ "always", BOND_PRI_RESELECT_ALWAYS, BOND_VALFLAG_DEFAULT},
174180
{ "better", BOND_PRI_RESELECT_BETTER, 0},
@@ -488,7 +494,7 @@ static const struct bond_option bond_opts[BOND_OPT_LAST] = {
488494
.id = BOND_OPT_PEER_NOTIF_DELAY,
489495
.name = "peer_notif_delay",
490496
.desc = "Delay between each peer notification on failover event, in milliseconds",
491-
.values = bond_intmax_tbl,
497+
.values = bond_peer_notif_delay_tbl,
492498
.set = bond_option_peer_notif_delay_set
493499
}
494500
};

include/net/bonding.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ struct bonding {
233233
*/
234234
spinlock_t mode_lock;
235235
spinlock_t stats_lock;
236-
u8 send_peer_notif;
236+
u32 send_peer_notif;
237237
u8 igmp_retrans;
238238
#ifdef CONFIG_PROC_FS
239239
struct proc_dir_entry *proc_entry;

0 commit comments

Comments
 (0)