Skip to contentSkip to conversation

video: arcfb: fix buffer overflow

PATCH Applied Vasiliy Kulikov 3 participants 4 messages Nov 21, 2010 – Nov 24, 2010

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

PATCH 1/1 video: arcfb: fix buffer overflow

(count + p) is not checked for integer overflow. If p < fbmemlength and count = (size_t)(1 - p) (very big unsigned integer) then count + p = 1 < fbmemlength and copy_to_user(base_addr+p, buf, count) overflows base_addr.

---
Compile tested only.

 drivers/video/arcfb.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/video/arcfb.c +1 -1
index 3ec4923..67a4cd4 100644
@@ -454,7 +454,7 @@ static ssize_t arcfb_write(struct fb_info *info, const char __user *buf,
 	xres = info->var.xres;
 	fbmemlength = (xres * info->var.yres)/8;
 
-	if (p > fbmemlength)
+	if (p > fbmemlength || (p + count < p))
 		return -ENOSPC;
 
 	err = 0;
Signature · 1 line
1.7.0.4
Applied
#1 lore raw
Quoted 6 lines · Vasiliy Kulikov

(count + p) is not checked for integer overflow. If p < fbmemlength and count = (size_t)(1 - p) (very big unsigned integer) then count + p = 1 < fbmemlength and copy_to_user(base_addr+p, buf, count) overflows base_addr.

Applied, thanks.

#2 lore raw
Quoted 9 lines · Paul Mundt
Quoted 6 lines · Vasiliy Kulikov

(count + p) is not checked for integer overflow. If p < fbmemlength and count = (size_t)(1 - p) (very big unsigned integer) then count + p = 1 < fbmemlength and copy_to_user(base_addr+p, buf, count) overflows base_addr.

Applied, thanks.

The patch is harmless, but the integer overflow would actually be caught in rw_verify_area().

regards,
dan carpenter

#3 lore raw
Quoted 7 lines · Dan Carpenter
Quoted 6 lines · Paul Mundt
Quoted 5 lines · Vasiliy Kulikov

(count + p) is not checked for integer overflow. If p < fbmemlength and count = (size_t)(1 - p) (very big unsigned integer) then count + p = 1 < fbmemlength and copy_to_user(base_addr+p, buf, count) overflows base_addr.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Applied, thanks.

The patch is harmless, but the integer overflow would actually be caught in rw_verify_area().

Ah, so it is, I'll drop it then, thanks.