Bug 7189

Summary: Inconsistent /proc/fb behavior
Product: Drivers Reporter: Jurij Smakov (jurij)
Component: Console/FramebuffersAssignee: Antonino Daplas (adaplas)
Status: RESOLVED CODE_FIX    
Severity: normal    
Priority: P2    
Hardware: i386   
OS: Linux   
Kernel Version: 2.6.17.13 Subsystem:
Regression: --- Bisected commit-id:

Description Jurij Smakov 2006-09-22 19:17:06 UTC
Distribution: Debian unstable
Hardware environment: Sparc Ultra60 workstation

Problem Description:
It appears that the function fbmem_read_proc, which serves as a backend for the
/proc/fb file, has a problem. When constructing the list of available frame
buffers to return to the user, it uses the following for-cycle;

for (fi = registered_fb; fi < &registered_fb[FB_MAX] && len < 4000; fi++)

Here len is the parameter passed to the function, that it the amount of data the
user is requesting from the file. So if the user requests a chunk larger than
4000 bytes, nothing is returned, leading to the peculiar behaviour described below.

Steps to reproduce:

$ cat /proc/fb
0 Creator 3D

This works fine, because strace shows that cat is reading data in 1024-byte chunks:
[..]
read(3, "0 Creator 3D\n", 1024)         = 13

OTOH, grep is reading data in 32kB chunks:
[..]
read(3, "", 32768)                      = 0

so the command 'grep Creator /proc/fb' returns nothing (quite unexpectingly). I
suspect that for-loop should have 'clen' rather than 'len', the local variable
which tracks the size of the buffer (even though I am not sure why one would
want to impose a 4000 byte limit here).