bonding: fix send_peer_notif overflow
[ Upstream commit 9949e2efb54eb3001cb2f6512ff3166dddbfb75d ] Bonding send_peer_notif was defined as u8. Since commit07a4ddec3c
("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 <liali@redhat.com> Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2090053 Fixes:07a4ddec3c
("bonding: add an option to specify a delay between peer notifications") Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
d9176dc690
commit
6b4585a3c9
@ -84,6 +84,11 @@ static int bond_fill_slave_info(struct sk_buff *skb,
|
|||||||
return -EMSGSIZE;
|
return -EMSGSIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Limit the max delay range to 300s */
|
||||||
|
static struct netlink_range_validation delay_range = {
|
||||||
|
.max = 300000,
|
||||||
|
};
|
||||||
|
|
||||||
static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = {
|
static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = {
|
||||||
[IFLA_BOND_MODE] = { .type = NLA_U8 },
|
[IFLA_BOND_MODE] = { .type = NLA_U8 },
|
||||||
[IFLA_BOND_ACTIVE_SLAVE] = { .type = NLA_U32 },
|
[IFLA_BOND_ACTIVE_SLAVE] = { .type = NLA_U32 },
|
||||||
@ -114,7 +119,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = {
|
|||||||
[IFLA_BOND_AD_ACTOR_SYSTEM] = { .type = NLA_BINARY,
|
[IFLA_BOND_AD_ACTOR_SYSTEM] = { .type = NLA_BINARY,
|
||||||
.len = ETH_ALEN },
|
.len = ETH_ALEN },
|
||||||
[IFLA_BOND_TLB_DYNAMIC_LB] = { .type = NLA_U8 },
|
[IFLA_BOND_TLB_DYNAMIC_LB] = { .type = NLA_U8 },
|
||||||
[IFLA_BOND_PEER_NOTIF_DELAY] = { .type = NLA_U32 },
|
[IFLA_BOND_PEER_NOTIF_DELAY] = NLA_POLICY_FULL_RANGE(NLA_U32, &delay_range),
|
||||||
[IFLA_BOND_MISSED_MAX] = { .type = NLA_U8 },
|
[IFLA_BOND_MISSED_MAX] = { .type = NLA_U8 },
|
||||||
[IFLA_BOND_NS_IP6_TARGET] = { .type = NLA_NESTED },
|
[IFLA_BOND_NS_IP6_TARGET] = { .type = NLA_NESTED },
|
||||||
};
|
};
|
||||||
|
@ -169,6 +169,12 @@ static const struct bond_opt_value bond_num_peer_notif_tbl[] = {
|
|||||||
{ NULL, -1, 0}
|
{ NULL, -1, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const struct bond_opt_value bond_peer_notif_delay_tbl[] = {
|
||||||
|
{ "off", 0, 0},
|
||||||
|
{ "maxval", 300000, BOND_VALFLAG_MAX},
|
||||||
|
{ NULL, -1, 0}
|
||||||
|
};
|
||||||
|
|
||||||
static const struct bond_opt_value bond_primary_reselect_tbl[] = {
|
static const struct bond_opt_value bond_primary_reselect_tbl[] = {
|
||||||
{ "always", BOND_PRI_RESELECT_ALWAYS, BOND_VALFLAG_DEFAULT},
|
{ "always", BOND_PRI_RESELECT_ALWAYS, BOND_VALFLAG_DEFAULT},
|
||||||
{ "better", BOND_PRI_RESELECT_BETTER, 0},
|
{ "better", BOND_PRI_RESELECT_BETTER, 0},
|
||||||
@ -488,7 +494,7 @@ static const struct bond_option bond_opts[BOND_OPT_LAST] = {
|
|||||||
.id = BOND_OPT_PEER_NOTIF_DELAY,
|
.id = BOND_OPT_PEER_NOTIF_DELAY,
|
||||||
.name = "peer_notif_delay",
|
.name = "peer_notif_delay",
|
||||||
.desc = "Delay between each peer notification on failover event, in milliseconds",
|
.desc = "Delay between each peer notification on failover event, in milliseconds",
|
||||||
.values = bond_intmax_tbl,
|
.values = bond_peer_notif_delay_tbl,
|
||||||
.set = bond_option_peer_notif_delay_set
|
.set = bond_option_peer_notif_delay_set
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -235,7 +235,7 @@ struct bonding {
|
|||||||
*/
|
*/
|
||||||
spinlock_t mode_lock;
|
spinlock_t mode_lock;
|
||||||
spinlock_t stats_lock;
|
spinlock_t stats_lock;
|
||||||
u8 send_peer_notif;
|
u32 send_peer_notif;
|
||||||
u8 igmp_retrans;
|
u8 igmp_retrans;
|
||||||
#ifdef CONFIG_PROC_FS
|
#ifdef CONFIG_PROC_FS
|
||||||
struct proc_dir_entry *proc_entry;
|
struct proc_dir_entry *proc_entry;
|
||||||
|
Loading…
Reference in New Issue
Block a user