Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b869ccfa authored by Nikolay Aleksandrov's avatar Nikolay Aleksandrov Committed by David S. Miller
Browse files

bonding: fix two race conditions in bond_store_updelay/downdelay



This patch fixes two race conditions between bond_store_updelay/downdelay
and bond_store_miimon which could lead to division by zero as miimon can
be set to 0 while either updelay/downdelay are being set and thus miss the
zero check in the beginning, the zero div happens because updelay/downdelay
are stored as new_value / bond->params.miimon. Use rtnl to synchronize with
miimon setting.

CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: Veaceslav Falico <vfalico@redhat.com>
Signed-off-by: default avatarNikolay Aleksandrov <nikolay@redhat.com>
Acked-by: default avatarVeaceslav Falico <vfalico@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 98e09386
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -702,6 +702,8 @@ static ssize_t bonding_store_downdelay(struct device *d,
	int new_value, ret = count;
	int new_value, ret = count;
	struct bonding *bond = to_bond(d);
	struct bonding *bond = to_bond(d);


	if (!rtnl_trylock())
		return restart_syscall();
	if (!(bond->params.miimon)) {
	if (!(bond->params.miimon)) {
		pr_err("%s: Unable to set down delay as MII monitoring is disabled\n",
		pr_err("%s: Unable to set down delay as MII monitoring is disabled\n",
		       bond->dev->name);
		       bond->dev->name);
@@ -735,6 +737,7 @@ static ssize_t bonding_store_downdelay(struct device *d,
	}
	}


out:
out:
	rtnl_unlock();
	return ret;
	return ret;
}
}
static DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR,
static DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR,
@@ -757,6 +760,8 @@ static ssize_t bonding_store_updelay(struct device *d,
	int new_value, ret = count;
	int new_value, ret = count;
	struct bonding *bond = to_bond(d);
	struct bonding *bond = to_bond(d);


	if (!rtnl_trylock())
		return restart_syscall();
	if (!(bond->params.miimon)) {
	if (!(bond->params.miimon)) {
		pr_err("%s: Unable to set up delay as MII monitoring is disabled\n",
		pr_err("%s: Unable to set up delay as MII monitoring is disabled\n",
		       bond->dev->name);
		       bond->dev->name);
@@ -790,6 +795,7 @@ static ssize_t bonding_store_updelay(struct device *d,
	}
	}


out:
out:
	rtnl_unlock();
	return ret;
	return ret;
}
}
static DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR,
static DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR,