From owner-freebsd-bugs@FreeBSD.ORG Tue Dec 6 13:30:12 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 E3F9B1065670 for ; Tue, 6 Dec 2011 13:30:12 +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 D36B28FC13 for ; Tue, 6 Dec 2011 13:30:12 +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 pB6DUCR4086398 for ; Tue, 6 Dec 2011 13:30:12 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id pB6DUCB9086395; Tue, 6 Dec 2011 13:30:12 GMT (envelope-from gnats) Date: Tue, 6 Dec 2011 13:30:12 GMT Message-Id: <201112061330.pB6DUCB9086395@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: Tue, 06 Dec 2011 13:30:13 -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 Subject: Re: kern/163076: It is not possible to read in chunks from linprocfs and procfs. Date: Tue, 6 Dec 2011 15:21:36 +0200 On 2011-12-06, Poul-Henning Kamp wrote: > >Shouldn't sbuf_finish() then check s->s_error before appending the > >trailing '\0' and setting the SBUF_FINISHED flag? The problem in > >question wasn't caught earlier because sbuf_finish() happily finishes > >the buffer even if it has an error. > > I belive the code is written so that there is always reserved space > for the final '\0' > > sbuf_finish() should finish _any_ sbuf, and return zero only if > the finished buffer is fully OK. Anyway I find it inconsistent that you can successfully call sbuf_finish() and sbuf_data() but not for example sbuf_len() on an errored buffer. Thus you can "fix" the problem with the subtle change below. %%% Index: sys/fs/pseudofs/pseudofs_vnops.c =================================================================== --- sys/fs/pseudofs/pseudofs_vnops.c (revision 228153) +++ sys/fs/pseudofs/pseudofs_vnops.c (working copy) @@ -651,7 +651,7 @@ pfs_read(struct vop_read_args *va) } sbuf_finish(sb); - error = uiomove_frombuf(sbuf_data(sb), sbuf_len(sb), uio); + error = uiomove_frombuf(sbuf_data(sb), strlen(sbuf_data(sb)), uio); sbuf_delete(sb); ret: vn_lock(vn, locked | LK_RETRY); %%% -- Jaakko