Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Jeff Sturm <jsturm@gatecom.com>
To: Uncle George <gatgul@voicenet.com>
Cc: axp-list@redhat.com
Subject: Re: runaway klogd/syslogd happening now
Date: Tue, 6 Oct 1998 18:09:17 -0400 (EDT)	[thread overview]
Message-ID: <Pine.SV4.3.90.981006175313.5272A-100000@gatecoms> (raw)
In-Reply-To: <36195FC8.75B7E478@voicenet.com>


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
> > > <sc 49(140f3bc70,40,8)>
> >
> > 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


  parent reply	other threads:[~1998-10-06 22:14 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-10-05 21:24 runaway klogd/syslogd happening now Greg Lindahl
1998-10-06  0:09 ` Uncle George
1998-10-06  0:27   ` Barrett G. Lyon
1998-10-06  0:46     ` Uncle George
1998-10-06  0:45       ` Barrett G. Lyon
1998-10-06  7:12   ` Michal Jaegermann
1998-10-06 12:12     ` Craig P Prescott
1998-10-06 22:09   ` Jeff Sturm [this message]
1998-10-06 22:52     ` Peter Waltenberg
1998-10-07 10:22     ` Uncle George
  -- strict thread matches above, loose matches on Subject: below --
1998-10-06 15:47 Greg Lindahl
1998-10-06 16:05 ` Michal Jaegermann
1998-10-06 19:53 ` Quant-X Alpha Linux Support
1998-10-06 15:44 Greg Lindahl
1998-10-06 13:15 Greg Lindahl
1998-10-06 13:26 ` Barrett G. Lyon
1998-10-06 15:31 ` Michal Jaegermann
1998-10-04 21:20 Greg Lindahl
1998-10-04 21:48 ` B. James Phillippe
1998-10-04 23:24 ` Uncle George
1998-10-04 14:39 Greg Lindahl
     [not found] <199810030609.CAA23387@neptune.phys.ufl.edu>
1998-10-04 13:41 ` Uncle George
1998-10-03 15:03 David Levine
1998-10-03  7:12 Shane Steven Sturrock
1998-10-03  0:29 Greg Lindahl
1998-10-03  0:58 ` B. James Phillippe
1998-10-05  6:11   ` Craig P Prescott
1998-10-02 19:30 Craig P Prescott
1998-10-02 22:39 ` Uncle George
1998-10-03  0:02   ` Craig P Prescott
1998-10-03  3:00 ` Paul Tomblin
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox