Date: Mon, 8 Jul 2002 17:45:47 -0700 (PDT) From: David Dunham <dwdunham@isilon.com> To: freebsd-gnats-submit@FreeBSD.org Subject: misc/40363: Syslogd crashes in function markit Message-ID: <200207090045.g690jlNR030263@www.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 40363
>Category: misc
>Synopsis: Syslogd crashes in function markit
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Mon Jul 08 17:50:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: David Dunham
>Release: FreeBSD 5.0
>Organization:
Isilon Systems
>Environment:
FreeBSD dwd_1 5.0-20010301-CURRENT i386
>Description:
Syslogd crashes when it tries to access memory it has just freed.
In the function markit q is freed and then TAILQ_NEXT is called using q.
>How-To-Repeat:
This is extremely rare the only way I was able to get it to happen consistently was to change syslogd as follows:
--- syslogd.c.orig Mon Jul 8 17:26:21 2002
+++ syslogd.c Mon Jul 8 17:24:16 2002
@@ -1084,9 +1084,9 @@
break;
}
}
- if (writev(f->f_file, iov, 7) < 0) {
+ if (writev(f->f_file, iov, 7) < 0 || 1) {
int e = errno;
- (void)close(f->f_file);
+ /* (void)close(f->f_file);*/
if (f->f_un.f_pipe.f_pid > 0)
deadq_enter(f->f_un.f_pipe.f_pid,
f->f_un.f_pipe.f_pname);
You also should probably run electric fence or some other memory debugger.
>Fix:
Get the next on the queue from the iterator before freeing it.
--- syslogd.c.orig Mon Jul 8 17:26:21 2002
+++ syslogd.c Mon Jul 8 17:24:16 2002
@@ -1775,7 +1775,7 @@
markit(void)
{
struct filed *f;
- dq_t q;
+ dq_t q, next;
now = time((time_t *)NULL);
MarkSeq += TIMERINTVL;
@@ -1796,7 +1796,9 @@
}
/* Walk the dead queue, and see if we should signal somebody. */
- TAILQ_FOREACH(q, &deadq_head, dq_entries) {
+ for (q = TAILQ_FIRST(&deadq_head); q != NULL; q = next) {
+ next = TAILQ_NEXT(q, dq_entries);
+
switch (q->dq_timeout) {
case 0:
/* Already signalled once, try harder now. */
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200207090045.g690jlNR030263>
