From owner-freebsd-bugs@FreeBSD.ORG Mon Jun 6 09:50:02 2005 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id ADD0216A41C for ; Mon, 6 Jun 2005 09:50:02 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 26C0F43D1F for ; Mon, 6 Jun 2005 09:50:02 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j569o1Wt056162 for ; Mon, 6 Jun 2005 09:50:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j569o14n056161; Mon, 6 Jun 2005 09:50:01 GMT (envelope-from gnats) Resent-Date: Mon, 6 Jun 2005 09:50:01 GMT Resent-Message-Id: <200506060950.j569o14n056161@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, Andrey Simonenko Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AC7B516A41C for ; Mon, 6 Jun 2005 09:42:55 +0000 (GMT) (envelope-from simon@comsys.ntu-kpi.kiev.ua) Received: from comsys.ntu-kpi.kiev.ua (comsys.ntu-kpi.kiev.ua [195.245.194.142]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0E91843D53 for ; Mon, 6 Jun 2005 09:42:50 +0000 (GMT) (envelope-from simon@comsys.ntu-kpi.kiev.ua) Received: from pm514-9.comsys.ntu-kpi.kiev.ua (pm514-9.comsys.ntu-kpi.kiev.ua [10.18.54.109]) (authenticated bits=0) by comsys.ntu-kpi.kiev.ua (8.12.10/8.12.10) with ESMTP id j569mPQk061353 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 6 Jun 2005 12:48:27 +0300 (EEST) Received: by pm514-9.comsys.ntu-kpi.kiev.ua (Postfix, from userid 1000) id 9EA6FD9; Mon, 6 Jun 2005 12:41:32 +0300 (EEST) Message-Id: <20050606094132.GA374@pm514-9.comsys.ntu-kpi.kiev.ua> Date: Mon, 6 Jun 2005 12:41:32 +0300 From: Andrey Simonenko To: FreeBSD-gnats-submit@FreeBSD.org Cc: Subject: kern/81943: [patch] _assert_sbuf_integrity causes panic for zero length buffer 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: Mon, 06 Jun 2005 09:50:02 -0000 >Number: 81943 >Category: kern >Synopsis: _assert_sbuf_integrity causes panic for zero length buffer >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Jun 06 09:50:01 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Andrey Simonenko >Release: FreeBSD 5.4-RELEASE-p1 i386 >Organization: >Environment: FreeBSD >= 4.4 >Description: If INVARIANTS is enabled, then _assert_sbuf_integrity panics if s_len == 0 and s_size == 0. Really this is not a problem, since nothing was written in zero length buffer. On FreeBSD 5.4 if INVARIANTS are enabled and procfs is mounted, then anybody can read zero bytes from /proc//map and the system will panic. Solution: * apply the patch given below, to allow s_len == 0 and s_size == 0 in sbuf * don't allocate zero length sbuf at all, but currently malloc(9) accepts zero length allocations, there is relevant #if 0 in source of malloc(9), this will require revision of all /sys files. >How-To-Repeat: Enable INVARIANTS, mount procfs and read zero bytes from /proc//map and see panic >Fix: --- subr_sbuf.c.orig Fri Jul 9 11:37:44 2004 +++ subr_sbuf.c Sat Jun 4 21:42:33 2005 @@ -91,7 +91,7 @@ ("%s called with a NULL sbuf pointer", fun)); KASSERT(s->s_buf != NULL, ("%s called with uninitialized or corrupt sbuf", fun)); - KASSERT(s->s_len < s->s_size, + KASSERT(s->s_len < s->s_size || s->s_len == 0, ("wrote past end of sbuf (%d >= %d)", s->s_len, s->s_size)); } >Release-Note: >Audit-Trail: >Unformatted: