From owner-freebsd-bugs@FreeBSD.ORG Sun Dec 11 10:30:05 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 0666C106564A for ; Sun, 11 Dec 2011 10:30:04 +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 DF69D8FC08 for ; Sun, 11 Dec 2011 10:30:04 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id pBBAU4mD032251 for ; Sun, 11 Dec 2011 10:30:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id pBBAU4fe032247; Sun, 11 Dec 2011 10:30:04 GMT (envelope-from gnats) Date: Sun, 11 Dec 2011 10:30:04 GMT Message-Id: <201112111030.pBBAU4fe032247@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Jaakko Heinonen Cc: Subject: Re: kern/163076: It is not possible to read in chunks from linprocfs and procfs. X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Jaakko Heinonen List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Dec 2011 10:30:05 -0000 The following reply was made to PR kern/163076; it has been noted by GNATS. From: Jaakko Heinonen To: Poul-Henning Kamp Cc: Petr Salinger , bug-followup@FreeBSD.org, des@FreeBSD.org, mdf@FreeBSD.org Subject: Re: kern/163076: It is not possible to read in chunks from linprocfs and procfs. Date: Sun, 11 Dec 2011 12:26:08 +0200 On 2011-12-10, Poul-Henning Kamp wrote: > I agree with Dag-Erling that it is at least mistake to not have > separate sbuf(9) and sbuf(3) pages, possibly also a mistake that > they share the implementation. One problem is the different malloc() semantics. The kernel version uses M_WAITOK allocations while user space malloc(3) can fail. > Obviously sbuf_finish() should return the error status, and its > return value SHALL be checked by applications, before the contents > of the sbuf can be used. Only 21 of 133 calls I grepped through the FreeBSD source tree did check the return value. In practice SBUF_AUTOEXTEND buffers can't fail when the kernel version is used (due to M_WAITOK malloc). > The argument relating to this bug is about what sbuf_len() and > sbuf_data() should return for an error'ed sbuf. > > Given that the mandatory error-check of the sbuf_finish() call > should prevent these two functions from being called in the first > place, I'm tempted to say that their return values should be > documented as undefined, and implemented to cause the maxium amount > of havoc (ie: -1 and NULL). -- Jaakko