From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 347 invoked from network); 6 Oct 1998 22:52:39 -0000 Received: from mail.redhat.com (199.183.24.239) by mail2.redhat.com with SMTP; 6 Oct 1998 22:52:39 -0000 Received: from funnelweb.surf.dascom.com (funnelweb.surf.dascom.com [203.22.125.2]) by mail.redhat.com (8.8.7/8.8.7) with ESMTP id SAA07791 for ; Tue, 6 Oct 1998 18:48:30 -0400 Received: from mulga.surf.dascom.com(10.129.0.81) by funnelweb.surf.dascom.com via smap (V2.1) id xma009240; Wed, 7 Oct 98 08:47:35 +1000 Message-ID: X-Mailer: XFMail 1.3 [p0] on Linux X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: Date: Wed, 07 Oct 1998 08:50:34 -0000=?us-ascii?Q?_(/etc/localtimep=97=12=08|=F7=FF=BF=3Dm =08?= Reply-To: peterw@dascom.com Sender: peterw@mulga.surf.dascom.com From: Peter Waltenberg To: axp-list@redhat.com Subject: Re: runaway klogd/syslogd happening now Cc: Uncle George On 06-Oct-98 Jeff Sturm wrote: > > 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?) > Fix it in klogd. 1) The kernel has suffered memory corruption, klogd gets passed a pointer to some random area of memory. 2) Someone supplies an inappropriate format specifier to printk, leading to a result akin to 1. I've done that, so I know it's possible. 3) It has happened to Intel users :), it just doesn't happen as often. Peter ---------------------------------- E-Mail: Peter Waltenberg Date: 07-Oct-98 Time: 08:45:38 This message was sent by XFMail ----------------------------------