drivers/staging/bcm: Integer overflow
PATCH 1/1 drivers/staging/bcm: Integer overflow
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 <[email protected]>
--- drivers/staging/bcm/nvm.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/staging/bcm/nvm.c +9 -0
@@ -3944,6 +3944,15 @@ int validateFlash2xReadWrite(struct bcm_mini_adapter *Adapter, struct bcm_flash2BCM_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;
Signature · 1 line
1.8.5.rc1.28.g7061504
Quoted 6 lines · Wenliang Fan
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 <[email protected]>
Looks good.
Reviewed-by Dan Carpenter <[email protected]>
regards,
dan carpenter