linprocfs Input/output error

Jaakko Heinonen jh at FreeBSD.org
Sat Jan 16 07:27:34 UTC 2010


On 2010-01-01, Jilles Tjoelker wrote:
> On Fri, Jan 01, 2010 at 06:45:33PM +0100, Fernando Apesteguía wrote:
> 
> > cat: /compat/linux/proc/cpuinfo: Input/output error
> 
> pfs_read() fails any read over MAXPHYS + 1 with EIO. This limit probably
> has to do with the allocation of a buffer of that size using sbuf_new(9)
> (and so, malloc(9)).
> 
> Some sort of limit seems appropriate, but MAXPHYS seems unrelated, and
> if the request is too long it should perhaps just truncate it.

With a quick test this patch seems to work:

%%%
Index: sys/fs/pseudofs/pseudofs_vnops.c
===================================================================
--- sys/fs/pseudofs/pseudofs_vnops.c	(revision 202405)
+++ sys/fs/pseudofs/pseudofs_vnops.c	(working copy)
@@ -637,10 +637,8 @@ pfs_read(struct vop_read_args *va)
 		error = EINVAL;
 		goto ret;
 	}
-	if (buflen > MAXPHYS + 1) {
-		error = EIO;
-		goto ret;
-	}
+	if (buflen > MAXPHYS + 1)
+		buflen = MAXPHYS + 1;
 
 	sb = sbuf_new(sb, NULL, buflen, 0);
 	if (sb == NULL) {
%%%

Maybe des@ can comment if this looks sane?

-- 
Jaakko


More information about the freebsd-hackers mailing list