kern/163076: It is not possible to read in chunks from linprocfs and procfs.

Jaakko Heinonen jh at FreeBSD.org
Sun Dec 11 10:30:05 UTC 2011


The following reply was made to PR kern/163076; it has been noted by GNATS.

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


More information about the freebsd-bugs mailing list