Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Dec 2011 10:30:04 GMT
From:      Jaakko Heinonen <jh@FreeBSD.org>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: kern/163076: It is not possible to read in chunks from linprocfs and procfs.
Message-ID:  <201112111030.pBBAU4fe032247@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/163076; it has been noted by GNATS.

From: Jaakko Heinonen <jh@FreeBSD.org>
To: Poul-Henning Kamp <phk@phk.freebsd.dk>
Cc: Petr Salinger <Petr.Salinger@seznam.cz>, 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201112111030.pBBAU4fe032247>