drivers/staging/bcm: Integer overflow
authorWenliang Fan <fanwlexca@gmail.com>
Fri, 20 Dec 2013 11:07:38 +0000 (19:07 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 20 Dec 2013 20:22:26 +0000 (12:22 -0800)
The checking condition in 'validateFlash2xReadWrite()' is not
sufficient. A large number invalid would cause an integer overflow and
pass the condition, which could cause further integer overflows in
'Bcmchar.c:bcm_char_ioctl()'.

Signed-off-by: Wenliang Fan <fanwlexca@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/bcm/nvm.c

index 9e5f955..3165da8 100644 (file)
@@ -3944,6 +3944,15 @@ int validateFlash2xReadWrite(struct bcm_mini_adapter *Adapter, struct bcm_flash2
 
        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "End offset :%x\n", uiSectEndOffset);
 
+       /* psFlash2xReadWrite->offset and uiNumOfBytes are user controlled and can lead to integer overflows */
+       if (psFlash2xReadWrite->offset > uiSectEndOffset) {
+               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Invalid Request....");
+               return false;
+       }
+       if (uiNumOfBytes > uiSectEndOffset) {
+               BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Invalid Request....");
+               return false;
+       }
        /* Checking the boundary condition */
        if ((uiSectStartOffset + psFlash2xReadWrite->offset + uiNumOfBytes) <= uiSectEndOffset)
                return TRUE;