From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 12131 invoked from network); 6 Oct 1998 22:14:05 -0000 Received: from mail.redhat.com (199.183.24.239) by mail2.redhat.com with SMTP; 6 Oct 1998 22:14:05 -0000 Received: from gatecoms.gatecom.com (gatecoms.gatecom.com [198.87.96.251]) by mail.redhat.com (8.8.7/8.8.7) with ESMTP id SAA06036 for ; Tue, 6 Oct 1998 18:09:57 -0400 Received: (from jsturm@localhost) by gatecoms.gatecom.com (8.8.7/8.8.7) id SAA06397; Tue, 6 Oct 1998 18:09:17 -0400 (EDT) Date: Tue, 6 Oct 1998 18:09:17 -0400 (EDT) From: Jeff Sturm X-Sender: jsturm@gatecoms To: Uncle George cc: axp-list@redhat.com Subject: Re: runaway klogd/syslogd happening now In-Reply-To: <36195FC8.75B7E478@voicenet.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII I've been following this discussion for awhile... I'm curious why there hasn't been any discussion of the klogd source since it is so little. My SX has never experienced the klogd runaway so I can't easily debug the problem, but a quick read through reveals problems in klogd.c: static void LogLine(char *ptr, int len) { auto int idx = 0; static int index = 0; auto char *nl; static char line[LOG_LINE_LENGTH], eline[LOG_LINE_LENGTH]; ... while (len) { nl = strpbrk(ptr, "\r\n"); /* Find first line terminator */ if (nl) { ... } else { strncat(line, ptr, len); index += len; len = 0; } } return; } Clearly there is a buffer overrun if the input buffer exceeds LOG_LINE_LENGTH (1024 bytes). Also the strpbrk call is dangerous, since the input buffer may not be terminated. Fixing this in the kernel is a good idea, but klogd must be fixed too before this happens again someday... (Why doesn't this bug affect Intel users? Have they never had a kernel that can generate /proc/kmsg messages longer than 1024 bytes?) Is anybody patching this? It can't be difficult, but I won't have a chance until sometime tomorrow... Jeff On Mon, 5 Oct 1998, Uncle George wrote: > actually its klogd that reads kern messages, like the one u posted. > > its probably better to fix the kern messages. after all, the 386 guys > arent complaining are they? > > Greg Lindahl wrote: > > > > [root@helix01 /root]# cat /proc/kmsg > > > > > > > Hm, that's right, unimplemented system calls do not have newlines > > after them. So if there were enough, that would cause memory > > corruption downstream in syslogd. > > > > So let's make a patch for syslogd which inserts a newline if > > the buffer is growing too close to the limit. > > > > -- g