Skip to contentSkip to conversation

fbcon: rotate upside down crash

PATCH In review Stefani Seibold 2 participants 2 messages Jul 28, 2009 – Jul 29, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fbcon: rotate upside down crash

Attached is a bug fix for the frame console.

The current frame buffer console upside down functionality will crash using a font which has not a width of multiple by 8.

The following 1 liner will fix the rotate_ud() function,

ChangeLog:
Fix the rotate_ud() function not to crash in case of a font which has not a width of multiple by 8: The inner loop of the font pixel copy should not access a bit outside the font memory area. Subtract the shift offset from the font width will prevent this.

 fbcon_rotate.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/console/fbcon_rotate.h +1 -1
@@ -45,7 +45,7 @@
 	width = (width + 7) & ~7;
 
 	for (i = 0; i < height; i++) {
-		for (j = 0; j < width; j++) {
+		for (j = 0; j < width - shift; j++) {
 			if (pattern_test_bit(j, i, width, in))
 				pattern_set_bit(width - (1 + j + shift),
 						height - (1 + i),
#1 lore raw

(let's cc linux-fbdev-devel)

Quoted 20 lines · On Tue, 28 Jul 2009 10:01:58 +0200 Stefani Seibold <[email protected]> wrote:

Attached is a bug fix for the frame console.

The current frame buffer console upside down functionality will crash using a font which has not a width of multiple by 8.

The following 1 liner will fix the rotate_ud() function,

ChangeLog:
Fix the rotate_ud() function not to crash in case of a font which has not a width of multiple by 8: The inner loop of the font pixel copy should not access a bit outside the font memory area. Subtract the shift offset from the font width will prevent this.

 fbcon_rotate.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

drivers/video/console/fbcon_rotate.h line 51

Quoted 8 lines
drivers/video/console/fbcon_rotate.h +1 -1
@@ -45,7 +45,7 @@
 	width = (width + 7) & ~7;
 
 	for (i = 0; i < height; i++) {
-		for (j = 0; j < width; j++) {
+		for (j = 0; j < width - shift; j++) {
 			if (pattern_test_bit(j, i, width, in))
 				pattern_set_bit(width - (1 + j + shift),
 						height - (1 + i),

Thanks.

It seems that the bug has been there for a very very long time. I wonder why - presumably nobody has tried to do an upside-down rotate before.

So given that this code sees very little use, I guess it's pretty safe to merge the fix into 2.6.31.