lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1310608665-12216-1-git-send-email-andy@greyhouse.net>
Date:	Wed, 13 Jul 2011 21:57:45 -0400
From:	Andy Gospodarek <andy@...yhouse.net>
To:	netdev@...r.kernel.org
Cc:	Takuma Umeya <tumeya@...hat.com>
Subject: [PATCH net-next] bonding: fix strlen errors in sysfs

When a bond contains a device where one name is the subset of another
(eth1 and eth10, for example), one cannot properly set the primary
device or the currently active device.

This was reported and based on work by Takuma Umeya.  I also verified
the problem and tested that this fix resolves it.

Signed-off-by: Andy Gospodarek <andy@...yhouse.net>
Reported-by: Takuma Umeya <tumeya@...hat.com>
---
 drivers/net/bonding/bond_sysfs.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index b60835f..50e859c 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -1037,9 +1037,9 @@ static ssize_t bonding_store_primary(struct device *d,
 			bond->dev->name, bond->dev->name, bond->params.mode);
 	} else {
 		bond_for_each_slave(bond, slave, i) {
-			if (strnicmp
-			    (slave->dev->name, buf,
-			     strlen(slave->dev->name)) == 0) {
+			int max_len = max(strlen(slave->dev->name),
+					  strlen(buf) - 1);
+			if (strnicmp(slave->dev->name, buf, max_len) == 0) {
 				pr_info("%s: Setting %s as primary slave.\n",
 					bond->dev->name, slave->dev->name);
 				bond->primary_slave = slave;
@@ -1208,9 +1208,9 @@ static ssize_t bonding_store_active_slave(struct device *d,
 			bond->dev->name, bond->dev->name, bond->params.mode);
 	else {
 		bond_for_each_slave(bond, slave, i) {
-			if (strnicmp
-			    (slave->dev->name, buf,
-			     strlen(slave->dev->name)) == 0) {
+			int max_len = max(strlen(slave->dev->name),
+					  strlen(buf) - 1);
+			if (strnicmp(slave->dev->name, buf, max_len) == 0) {
         			old_active = bond->curr_active_slave;
         			new_active = slave;
         			if (new_active == old_active) {
-- 
1.7.4.4

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ