From owner-freebsd-bugs@FreeBSD.ORG Sat Aug 13 22:50:08 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3FDCC106566C for ; Sat, 13 Aug 2011 22:50:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 043298FC0A for ; Sat, 13 Aug 2011 22:50:08 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p7DMo73d025769 for ; Sat, 13 Aug 2011 22:50:07 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p7DMo7w3025768; Sat, 13 Aug 2011 22:50:07 GMT (envelope-from gnats) Resent-Date: Sat, 13 Aug 2011 22:50:07 GMT Resent-Message-Id: <201108132250.p7DMo7w3025768@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Steve Wills Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CCCC9106564A for ; Sat, 13 Aug 2011 22:47:18 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id BD02D8FC0A for ; Sat, 13 Aug 2011 22:47:18 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p7DMlIpm082831 for ; Sat, 13 Aug 2011 22:47:18 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id p7DMlItV082821; Sat, 13 Aug 2011 22:47:18 GMT (envelope-from nobody) Message-Id: <201108132247.p7DMlItV082821@red.freebsd.org> Date: Sat, 13 Aug 2011 22:47:18 GMT From: Steve Wills To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/159750: [PATCH] /usr/bin/tail can call fclose(NULL) causing core dump X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Aug 2011 22:50:08 -0000 >Number: 159750 >Category: bin >Synopsis: [PATCH] /usr/bin/tail can call fclose(NULL) causing core dump >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Aug 13 22:50:07 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Steve Wills >Release: >Organization: >Environment: >Description: I've been getting core dumps from tail when the FS it's on disappears. It can call fclose with a NULL argument, which causes the crash. >How-To-Repeat: run tail -F /path/to/file/on/md, then destroy the md(4) >Fix: See attached. Patch attached with submission follows: --- usr.bin/tail/forward.c.orig 2011-08-13 18:04:19.054770069 -0400 +++ usr.bin/tail/forward.c 2011-08-13 18:04:23.822771648 -0400 @@ -361,7 +361,9 @@ if (errno != ENOENT) ierr(file->file_name); show(file); - fclose(file->fp); + if (file->fp != NULL) { + fclose(file->fp); + } file->fp = NULL; ev_change++; continue; >Release-Note: >Audit-Trail: >Unformatted: