Skip to contentSkip to conversation

b44 WOL setup: one-bit-off stack corruption kernel panic fix

PATCH Applied Stanislav Brabec 2 participants 5 messages Dec 2, 2009 – Dec 9, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 b44 WOL setup: one-bit-off stack corruption kernel panic fix

About 50% of shutdowns of b44 Ethernet adapter ends by kernel panic with kernels compiled with stack-protector.

Checking b44_magic_pattern() return values, one call of b44_magic_pattern() returns 127. It means, that set_bit(128, pmask) was called on line 1509. It means that bit 0 of 17th byte of pmask was overwritten. But pmask has only 16 bytes. Stack corruption happens.

It seems that set_bit() on line 1509 always writes one bit off.

The fix does not only solve the stack corruption, but also makes Wake On LAN working on my onboard B44 on Asus A7V-333X mainboard.

It seems that this problem affects all kernel versions since commit 725ad800 on 2006-06-20.

drivers/net/b44.c +1 -2
index 2a91323..4869adb 100644
@@ -1505,8 +1505,7 @@ static int b44_magic_pattern(u8 *macaddr, u8 *ppattern, u8 *pmask, int offset)
 		for (k = 0; k< ethaddr_bytes; k++) {
 			ppattern[offset + magicsync +
 				(j * ETH_ALEN) + k] = macaddr[k];
-			len++;
-			set_bit(len, (unsigned long *) pmask);
+			set_bit(len++, (unsigned long *) pmask);
 		}
 	}
 	return len - 1;
Signature · 9 lines
Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o.                          e-mail: [email protected]
Lihovarská 1060/12           tel: +420 284 028 966, +49 911 740538747
190 00 Praha 9                                  fax: +420 284 028 951
Czech Republic                                    http://www.suse.cz/
#1 lore raw
Quoted 8 lines · Stanislav Brabec

About 50% of shutdowns of b44 Ethernet adapter ends by kernel panic with kernels compiled with stack-protector.

Checking b44_magic_pattern() return values, one call of b44_magic_pattern() returns 127. It means, that set_bit(128, pmask) was called on line 1509. It means that bit 0 of 17th byte of pmask was overwritten. But pmask has only 16 bytes. Stack corruption happens.

Quoted 7 lines

It seems that set_bit() on line 1509 always writes one bit off.

The fix does not only solve the stack corruption, but also makes Wake On LAN working on my onboard B44 on Asus A7V-333X mainboard.

It seems that this problem affects all kernel versions since commit 725ad800 on 2006-06-20.

[email protected] may be interested as well. Adding Cc:.

drivers/net/b44.c +1 -2
index 2a91323..4869adb 100644
@@ -1505,8 +1505,7 @@ static int b44_magic_pattern(u8 *macaddr, u8 *ppattern, u8 *pmask, int offset)
 		for (k = 0; k< ethaddr_bytes; k++) {
 			ppattern[offset + magicsync +
 				(j * ETH_ALEN) + k] = macaddr[k];
-			len++;
-			set_bit(len, (unsigned long *) pmask);
+			set_bit(len++, (unsigned long *) pmask);
 		}
 	}
 	return len - 1;
Signature · 9 lines
Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o.                          e-mail: [email protected]
Lihovarská 1060/12           tel: +420 284 028 966, +49 911 740538747
190 00 Praha 9                                  fax: +420 284 028 951
Czech Republic                                    http://www.suse.cz/
maintainer
#2 lore raw

From: Stanislav Brabec <[email protected]>
Date: Wed, 02 Dec 2009 15:35:20 +0100

Quoted 11 lines
Quoted 10 lines · Stanislav Brabec

About 50% of shutdowns of b44 Ethernet adapter ends by kernel panic with kernels compiled with stack-protector.

Checking b44_magic_pattern() return values, one call of b44_magic_pattern() returns 127. It means, that set_bit(128, pmask) was called on line 1509. It means that bit 0 of 17th byte of pmask was overwritten. But pmask has only 16 bytes. Stack corruption happens.

It seems that set_bit() on line 1509 always writes one bit off.

Quoted 7 lines
Quoted 5 lines

The fix does not only solve the stack corruption, but also makes Wake On LAN working on my onboard B44 on Asus A7V-333X mainboard.

It seems that this problem affects all kernel versions since commit 725ad800 on 2006-06-20.

[email protected] may be interested as well. Adding Cc:.

[email protected] is even more interested. Please post all networking patches CC:'d there so they get properly logged and tracked in patchwork.

Thank you.

#3 lore raw
Quoted 11 lines · David Miller

From: Stanislav Brabec <[email protected]>
Date: Wed, 02 Dec 2009 15:35:20 +0100

Quoted 5 lines
Quoted 3 lines

It seems that this problem affects all kernel versions since commit 725ad800 on 2006-06-20.

[email protected] may be interested as well. Adding Cc:.

[email protected] is even more interested. Please post all networking patches CC:'d there so they get properly logged and tracked in patchwork.

OK, sending again with another Cc::

About 50% of shutdowns of b44 Ethernet adapter ends by kernel panic with kernels compiled with stack-protector.

Checking b44_magic_pattern() return values, one call of b44_magic_pattern() returns 127. It means, that set_bit(128, pmask) was called on line 1509. It means that bit 0 of 17th byte of pmask was overwritten. But pmask has only 16 bytes. Stack corruption happens.

It seems that set_bit() on line 1509 always writes one bit off.

The fix does not only solve the stack corruption, but also makes Wake On LAN working on my onboard B44 on Asus A7V-333X mainboard.

It seems that this problem affects all kernel versions since commit 725ad800 on 2006-06-20.

drivers/net/b44.c +1 -2
index 2a91323..4869adb 100644
@@ -1505,8 +1505,7 @@ static int b44_magic_pattern(u8 *macaddr, u8 *ppattern, u8 *pmask, int offset)
                for (k = 0; k< ethaddr_bytes; k++) {
                        ppattern[offset + magicsync +
                                (j * ETH_ALEN) + k] = macaddr[k];
-                       len++;
-                       set_bit(len, (unsigned long *) pmask);
+                       set_bit(len++, (unsigned long *) pmask);
                }
        }
        return len - 1;
Signature · 9 lines
Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o.                          e-mail: [email protected]
Lihovarská 1060/12           tel: +420 284 028 966, +49 911 740538747
190 00 Praha 9                                  fax: +420 284 028 951
Czech Republic                                    http://www.suse.cz/
maintainer Applied
#4 lore raw

From: Stanislav Brabec <[email protected]>
Date: Thu, 03 Dec 2009 15:56:28 +0100

Quoted 10 lines

About 50% of shutdowns of b44 Ethernet adapter ends by kernel panic with kernels compiled with stack-protector.

Checking b44_magic_pattern() return values, one call of b44_magic_pattern() returns 127. It means, that set_bit(128, pmask) was called on line 1509. It means that bit 0 of 17th byte of pmask was overwritten. But pmask has only 16 bytes. Stack corruption happens.

It seems that set_bit() on line 1509 always writes one bit off.

Quoted 7 lines

The fix does not only solve the stack corruption, but also makes Wake On LAN working on my onboard B44 on Asus A7V-333X mainboard.

It seems that this problem affects all kernel versions since commit 725ad800 on 2006-06-20.

Applied, thanks.