Skip to contentSkip to conversation

klogd busy loop on zero byte (output from 3c59x driver)

PATCH In review Troels Walsted Hansen 4 participants 5 messages Jan 11, 2001

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 klogd busy loop on zero byte (output from 3c59x driver)

Hi all.

I found a bug in the sysklogd package version 1.4. When it encounters a zero byte in the kernel logging output, the text parser enters a busy loop. I came upon it when the 3c59x driver from kernel 2.4.0 started outputting two zero bytes for the product code of my laptop's 3Com card. It could be argued that the kernel should never output zero bytes in the logging info, but obviously that will happen from time to time.

I fear this bug might be considered a security issue as well, if the kernel can be coerced to output a zero byte somehow, all kernel logging will stop.

I have included a patch to klogd.c to correct the issue.

klogd.c +7 -0
@@ -739,6 +758,13 @@
 		  break;  /* full line_buff or end of input buffer */
                }
 
+               if( *ptr == '\0' ) /* zero byte */
+               {
+                  ptr++;	/* skip zero byte */
+                  space -= 1;
+                  len   -= 1;
+                  break;
+               }
                if( *ptr == '\n' )  /* newline */
                {
                   ptr++;	/* skip newline */

--
Troels Walsted Hansen
[email protected]

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#1 lore raw

Zitiere Troels Walsted Hansen <[email protected]>:

Quoted 5 lines

Hi all.

I found a bug in the sysklogd package version 1.4. When it encounters a zero
byte in the kernel logging output, the text parser enters a busy loop.

That finally explains the "klogd eats 100% cpu time" reports with ~2.2.10:

We (I and Andrea) fixed several bugs in the kernel code, but none of them explained why klogd entered a busy loop.

--
Manfred
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#2 lore raw
In reply to Troels Walsted Hansen
Quoted 9 lines · Troels Walsted Hansen

Hi all.

I found a bug in the sysklogd package version 1.4. When it encounters a zero byte in the kernel logging output, the text parser enters a busy loop. I came upon it when the 3c59x driver from kernel 2.4.0 started outputting two zero bytes for the product code of my laptop's 3Com card. It could be argued that the kernel should never output zero bytes in the logging info, but obviously that will happen from time to time.

Yep. %02x%02x it now is.

The code in question was snitched from pcmcia-cs's 3c575_cb.c, and I assume David would have heard if it was busting klogd. Maybe there's a klogd version problem, or maybe your NIC's EEPROM is hosed?

-
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#3 lore raw
Quoted 1 line

Yep. %02x%02x it now is.

I suppose it might be worthwhile to search the kernel sources for other instances of printk("%c"), there's no telling when all distributions will be up to date with new sysklogd releases...

Quoted 3 lines

The code in question was snitched from pcmcia-cs's 3c575_cb.c, and I assume David would have heard if it was busting klogd. Maybe there's a klogd version problem, or maybe your NIC's EEPROM is hosed?

I believe I have the latest version of klogd...

My NIC is a 3Com PCI 3c556 Laptop Tornado, in a Dell Latitude C600 laptop. The driver reports the product code as "00" and the rev as "00.0", the date however is "03-01-00" which sounds fairly reasonable (although the laptop is brand new).

Needless to say, it also works fine, otherwise I would probably have attacked the driver first...

--
Troels Walsted Hansen
[email protected]

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#4 lore raw
In reply to Troels Walsted Hansen
Quoted 6 lines · Andrew Morton

Yep. %02x%02x it now is.

The code in question was snitched from pcmcia-cs's 3c575_cb.c, and I assume David would have heard if it was busting klogd. Maybe there's a klogd version problem, or maybe your NIC's EEPROM is hosed?

I haven't heard of it before: I've never seen a card claim to have 0's for its ascii product code. What card is it, exactly?

-- Dave
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/