lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20131220091255.GR5443@mwanda>
Date:	Fri, 20 Dec 2013 12:12:55 +0300
From:	Dan Carpenter <dan.carpenter@...cle.com>
To:	Wenliang Fan <fanwlexca@...il.com>
Cc:	gregkh <gregkh@...uxfoundation.org>,
	klmckinney1 <klmckinney1@...il.com>,
	tulinizer <tulinizer@...il.com>,
	devel <devel@...verdev.osuosl.org>,
	linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] drivers/staging/bcm: Integer overflow

On Fri, Dec 20, 2013 at 04:51:45PM +0800, Wenliang Fan wrote:
> Thanks for your advice.
> But the variable 'psFlash2xReadWrite->offset' in '
> *drivers/staging/bcm/nvm.c*:validateFlash2xReadWrite()' is also comes from
> user space, which would cause an integer overflow in the following line:
> 
> if ((uiSectStartOffset + psFlash2xReadWrite->offset + uiNumOfBytes) <=
> uiSectEndOffset)
> 
> in '*drivers/staging/bcm/**nvm.c*: validateFlash2xReadWrite()',
> and another integer overflow in the following line:
> 
> 
> ReadOffset = ReadOffset + ReadBytes; (or WriteOffset = WriteOffset +
> WriteBytes;)
> 
> in '*drivers/staging/bcm/**Bcmchar.c*: bcm_char_ioctl()'.
> 

Alright, fine.  But the new check is messy.  Do it like this:

	/* these are user controlled and can lead to integer overflows */
	if (psFlash2xReadWrite->offset > uiSectEndOffset)
		return false;
	if (uiNumOfBytes > uiSectEndOffset)
		return false;
	if (uiSectStartOffset + psFlash2xReadWrite->offset + uiNumOfBytes > uiSectEndOffset)
		return false;

	return true;

That way each step is simpler to understand.  People are too fond of
compound conditions... *grumble*.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ