Skip to contentSkip to conversation

New: Inconsistent /proc/fb behavior

Bugme-new Andrew Morton 4 participants 5 messages Sep 23, 2006 – Sep 27, 2006 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

Begin forwarded message:

Date: Fri, 22 Sep 2006 19:27:02 -0700
From: [email protected]
To: [email protected]
Subject: [Bugme-new] [Bug 7189] New: Inconsistent /proc/fb behavior

http://bugzilla.kernel.org/show_bug.cgi?id=7189

Summary: Inconsistent /proc/fb behavior
Kernel Version: 2.6.17.13
Status: NEW
Severity: normal
Owner: [email protected]
Submitter: [email protected]

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).

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#1 lore raw
Quoted 35 lines · Andrew Morton

Begin forwarded message:

http://bugzilla.kernel.org/show_bug.cgi?id=7189

Summary: Inconsistent /proc/fb behavior
Kernel Version: 2.6.17.13
Status: NEW
Severity: normal
Owner: [email protected]
Submitter: [email protected]

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

Quoted 8 lines

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).

I guess it should check clen', not len'. Can you please try this patch? It should apply to 2.4.34-pre3, too.

[PATCH] Correct buffer size limit in fbmem_read_proc()

drivers/video/fbmem.c renamed from drivers/video/fbmem.c.orig +2 -1
@@ -554,7 +554,8 @@ static int fbmem_read_proc(char *buf, ch
 	int clen;
 
 	clen = 0;
-	for (fi = registered_fb; fi < &registered_fb[FB_MAX] && len < 4000; fi++)
+	for (fi = registered_fb; fi < &registered_fb[FB_MAX] && clen < 4000;
+	     fi++)
 		if (*fi)
 			clen += sprintf(buf + clen, "%d %s\n",
 				        (*fi)->node,

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#2 lore raw
Quoted 56 lines · On Sun, 24 Sep 2006 12:31:30 +0200 (CEST) Geert Uytterhoeven…
Quoted 35 lines · Andrew Morton

Begin forwarded message:

http://bugzilla.kernel.org/show_bug.cgi?id=7189

Summary: Inconsistent /proc/fb behavior
Kernel Version: 2.6.17.13
Status: NEW
Severity: normal
Owner: [email protected]
Submitter: [email protected]

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

Quoted 8 lines

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).

I guess it should check clen', not len'. Can you please try this patch? It should apply to 2.4.34-pre3, too.

[PATCH] Correct buffer size limit in fbmem_read_proc()

drivers/video/fbmem.c static int fbmem_read_proc(char *buf, ch · line 561

Quoted 9 lines
drivers/video/fbmem.c renamed from drivers/video/fbmem.c.orig +2 -1
@@ -554,7 +554,8 @@ static int fbmem_read_proc(char *buf, ch
 	int clen;
 
 	clen = 0;
-	for (fi = registered_fb; fi < &registered_fb[FB_MAX] && len < 4000; fi++)
+	for (fi = registered_fb; fi < &registered_fb[FB_MAX] && clen < 4000;
+	     fi++)
 		if (*fi)
 			clen += sprintf(buf + clen, "%d %s\n",
 				        (*fi)->node,

Thanks. Do we have confirmation that this patch fixes the bug?

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#3 lore raw
Quoted 2 lines · Andrew Morton

On Sun, 24 Sep 2006 12:31:30 +0200 (CEST)
Geert Uytterhoeven <[email protected]> wrote:

[...]

Quoted 9 lines
Quoted 9 lines

[PATCH] Correct buffer size limit in fbmem_read_proc()

drivers/video/fbmem.c renamed from drivers/video/fbmem.c.orig +0 -0
@@ -554,7 +554,8 @@ static int fbmem_read_proc(char *buf, ch
 	int clen;
 
Quoted 10 lines

drivers/video/fbmem.c static int fbmem_read_proc(char *buf, ch · line 561

Quoted 8 lines
drivers/video/fbmem.c renamed from drivers/video/fbmem.c.orig +2 -1
 	clen = 0;
-	for (fi = registered_fb; fi < &registered_fb[FB_MAX] && len < 4000; fi++)
+	for (fi = registered_fb; fi < &registered_fb[FB_MAX] && clen < 4000;
+	     fi++)
 		if (*fi)
 			clen += sprintf(buf + clen, "%d %s\n",
 				        (*fi)->node,

Thanks. Do we have confirmation that this patch fixes the bug?

Sorry for not replying sooner. Today I've built a 2.6.18 kernel with this patch and it did fix the problem. Grepping through /proc/fb now works as expected on my Sparc.

Best regards,

Signature · 8 lines
Jurij Smakov                                        [email protected]
Key: http://www.wooyd.org/pgpkey/                   KeyID: C99E03CC

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
#4 lore raw
Quoted 24 lines · Jurij Smakov
Quoted 2 lines · Andrew Morton

On Sun, 24 Sep 2006 12:31:30 +0200 (CEST)
Geert Uytterhoeven <[email protected]> wrote:

[...]

Quoted 9 lines
Quoted 9 lines

[PATCH] Correct buffer size limit in fbmem_read_proc()

drivers/video/fbmem.c renamed from drivers/video/fbmem.c.orig +0 -0
@@ -554,7 +554,8 @@ static int fbmem_read_proc(char *buf, ch
 	int clen;
 
Quoted 10 lines

drivers/video/fbmem.c static int fbmem_read_proc(char *buf, ch · line 561

Quoted 8 lines
drivers/video/fbmem.c renamed from drivers/video/fbmem.c.orig +2 -1
 	clen = 0;
-	for (fi = registered_fb; fi < &registered_fb[FB_MAX] && len < 4000; fi++)
+	for (fi = registered_fb; fi < &registered_fb[FB_MAX] && clen < 4000;
+	     fi++)
 		if (*fi)
 			clen += sprintf(buf + clen, "%d %s\n",
 				        (*fi)->node,

Thanks. Do we have confirmation that this patch fixes the bug?

Quoted 3 lines

Sorry for not replying sooner. Today I've built a 2.6.18 kernel with this patch and it did fix the problem. Grepping through /proc/fb now works as expected on my Sparc.

Thanks for the feedback, then I'm queueing it for 2.4.34-pre4 too.

Cheers,
Willy

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV