Skip to contentSkip to conversation

lcd: Add checks to CAP_SYS_ADMIN to potentially dangerous ioctl's

PATCH New James Nelson 2 participants 3 messages Jan 28, 2005 – Jan 30, 2005 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lcd: Add checks to CAP_SYS_ADMIN to potentially dangerous ioctl's

This patch adds CAP_SYS_ADMIN checks to the potentially dangerous ioctls FLASH_Erase and FLASH_Burn in the Cobalt LCD interface driver.

drivers/char/lcd.c +4 -0
diff -purN --exclude='*~' linux-2.4.29-original/drivers/char/lcd.c linux-2.4.29/drivers/char/lcd.c
@@ -386,6 +386,8 @@ static int lcd_ioctl(struct inode *inode
 
 		int ctr=0;
 
+		if (!capable(CAP_SYS_ADMIN)) return -EPERM;
+
 		    // Chip Erase Sequence
 		WRITE_FLASH( kFlash_Addr1, kFlash_Data1 );
 		WRITE_FLASH( kFlash_Addr2, kFlash_Data2 );
@@ -422,6 +424,8 @@ static int lcd_ioctl(struct inode *inode
 
                 struct lcd_display display;
 
+		if (!capable(CAP_SYS_ADMIN)) return -EPERM;
+
                 if(copy_from_user(&display, (struct lcd_display*)arg, sizeof(struct lcd_display)))
 		  return -EFAULT;
 		rom = (unsigned char *) kmalloc((128),GFP_ATOMIC);
#1 lore raw

PATCH 1/1 lcd: fix memory leak in lcd_ioctl()

This patch fixes a memory leak in the FLASH_Burn ioctl for the Cobalt LCD interface driver.

drivers/char/lcd.c +3 -1
diff -purN --exclude='*~' linux-2.4.29-original/drivers/char/lcd.c linux-2.4.29/drivers/char/lcd.c
@@ -434,8 +434,10 @@ static int lcd_ioctl(struct inode *inode
 		save_flags(flags);
 		for (i=0; i<FLASH_SIZE; i=i+128) {
 
-		        if(copy_from_user(rom, display.RomImage + i, 128))
+		        if(copy_from_user(rom, display.RomImage + i, 128)) {
+			   kfree(rom);
 			   return -EFAULT;
+			}
 			burn_addr = kFlashBase + i;
 			cli();
 			for ( index = 0; index < ( 128 ) ; index++ ) 
#2 lore raw

Re: [PATCH 2.4] lcd: fix memory leak in lcd_ioctl()

Applied both, thanks James.

Quoted 3 lines · James Nelson

This patch fixes a memory leak in the FLASH_Burn ioctl for the Cobalt LCD interface driver.