Skip to contentSkip to conversation

staging/bcm: integer underflow leads to Oom

PATCH In review Dan Carpenter 1 participant 1 message Feb 17, 2014

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

PATCH 2/2 staging/bcm: integer underflow leads to Oom

We do:

        if (NOB > DEFAULT_BUFF_SIZE)
                BuffSize = DEFAULT_BUFF_SIZE;
        else
                BuffSize = NOB;

Since NOB can be negative it results in a larger than intended BuffSize and makes kzalloc() fail.

The code is still a bit crap because it lets the users read as much as they want from nvram, but I don't know what a sensible upper limit should be.

drivers/staging/bcm/Bcmchar.c +1 -1
index 6f1997dc44c8..5e4dfe031040 100644
@@ -1894,7 +1894,7 @@ static int bcm_char_ioctl_nvm_raw_read(void __user *argp, struct bcm_mini_adapte
 {
 	struct bcm_nvm_readwrite stNVMRead;
 	struct bcm_ioctl_buffer IoBuffer;
-	INT NOB;
+	unsigned int NOB;
 	INT BuffSize;
 	INT ReadOffset = 0;
 	UINT ReadBytes = 0;