NetBSD Problem Report #47055

From dholland@netbsd.org  Wed Oct 10 19:44:55 2012
Return-Path: <dholland@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id F39DC63B90D
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 10 Oct 2012 19:44:54 +0000 (UTC)
Message-Id: <20121010194454.E495214A155@mail.netbsd.org>
Date: Wed, 10 Oct 2012 19:44:54 +0000 (UTC)
From: dholland@NetBSD.org
Reply-To: dholland@NetBSD.org
To: gnats-bugs@gnats.NetBSD.org
Subject: libc diagassert issues
X-Send-Pr-Version: 3.95

>Number:         47055
>Category:       lib
>Synopsis:       libc diagassert issues
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 10 19:45:00 +0000 2012
>Closed-Date:    Sun Oct 06 12:56:52 +0000 2013
>Last-Modified:  Sun Oct 06 12:56:52 +0000 2013
>Originator:     David A. Holland
>Release:        NetBSD 6.99.12 (20121010)
>Organization:
>Environment:
n/a
>Description:

There are two problems with libc diagassert:

(1) it calls syslog() blindly, so if an assertion happens in a program
that hasn't called openlog(), it ends up using uninitialized state in
syslog.c. The observable effect of this seems to be to issue syslog
messages with no hostname field; however, it could be (or become,
without much notice) a good deal worse.

(2) it isn't thread-safe. It frob a global variable (diagassert_flags)
without locking. It also should probably be using syslog_r() rather
than syslog().

>How-To-Repeat:

Build kde4, look at the resulting syslog spam. Then review the code.

>Fix:

Probably needs discussion.

>Release-Note:

>Audit-Trail:
From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, lib-bug-people@netbsd.org, 
	gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc: 
Subject: Re: lib/47055: libc diagassert issues
Date: Wed, 10 Oct 2012 18:45:29 -0400

 On Oct 10,  7:45pm, dholland@NetBSD.org (dholland@NetBSD.org) wrote:
 -- Subject: lib/47055: libc diagassert issues

 | There are two problems with libc diagassert:
 | 
 | (1) it calls syslog() blindly, so if an assertion happens in a program
 | that hasn't called openlog(), it ends up using uninitialized state in
 | syslog.c. The observable effect of this seems to be to issue syslog
 | messages with no hostname field; however, it could be (or become,
 | without much notice) a good deal worse.

 This is a bug. I am fixing and versioning syslog(). Syslog should be
 thread-safe, and because of the static hostname (and the initialiazation
 of it, it is not).

 christos

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/47055 CVS commit: src/lib/libc/gen
Date: Wed, 10 Oct 2012 18:50:51 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Wed Oct 10 22:50:51 UTC 2012

 Modified Files:
 	src/lib/libc/gen: syslog.c

 Log Message:
 PR/47055: David Holland: Remove static hostname and store the hostname in
 syslog_data. Initialize hostname before it is used. While here, add a version
 to syslog_data.


 To generate a diff of this commit:
 cvs rdiff -u -r1.50 -r1.51 src/lib/libc/gen/syslog.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/47055 CVS commit: src/sys/sys
Date: Wed, 10 Oct 2012 18:51:55 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Wed Oct 10 22:51:55 UTC 2012

 Modified Files:
 	src/sys/sys: syslog.h

 Log Message:
 PR/47055: David Holland: Add hostname to syslog_data, version number, rename
 fields consistently, and version library calls affected.


 To generate a diff of this commit:
 cvs rdiff -u -r1.34 -r1.35 src/sys/sys/syslog.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: matthew green <mrg@eterna.com.au>
To: gnats-bugs@NetBSD.org
Cc: lib-bug-people@netbsd.org, gnats-admin@netbsd.org,
    netbsd-bugs@netbsd.org
Subject: re: lib/47055: libc diagassert issues
Date: Thu, 11 Oct 2012 16:53:50 +1100

 > (1) it calls syslog() blindly, so if an assertion happens in a program
 > that hasn't called openlog(), it ends up using uninitialized state in
 > syslog.c. The observable effect of this seems to be to issue syslog
 > messages with no hostname field; however, it could be (or become,
 > without much notice) a good deal worse.

 that shouldn't be a problem.  it sounds like a bug in syslog(3) itself.
 i've never seen any requirement for openlog(3) being necessary and indeed
 our documentation says:

    The openlog() function provides for more specialized processing of the
    messages sent by syslog() and vsyslog().

 > (2) it isn't thread-safe. It frob a global variable (diagassert_flags)
 > without locking. It also should probably be using syslog_r() rather
 > than syslog().

 probably.  (i don't think we had syslog_r() back when diagassert
 first appeared...)


 .mrg.

State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 06 Oct 2013 12:56:52 +0000
State-Changed-Why:
fixed last year


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.