From: Sean Anderson Date: Mon, 19 Apr 2021 10:13:00 -0400 Subject: [PATCH] fastboot: Fix overflow when calculating chunk size In-Reply-To: <5497cb0e-b781-6810-5b17-f8e53631d99c@denx.de> References: <20210416215821.3575989-1-sean.anderson@seco.com> <5497cb0e-b781-6810-5b17-f8e53631d99c@denx.de> Message-ID: <2eac2844-78f3-162e-73c3-59f62bca8b3f@seco.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 4/19/21 12:31 AM, Heiko Schocher wrote: > Hello Sean, > > On 16.04.21 23:58, Sean Anderson wrote: >> If a chunk was larger than 4GiB, then chunk_data_sz would overflow and >> blkcnt would not be calculated correctly. Upgrade it to a u64 and cast >> its multiplicands as well. Also fix bytes_written while we're at it. >> >> Signed-off-by: Sean Anderson >> --- >> >> lib/image-sparse.c | 12 ++++++------ >> 1 file changed, 6 insertions(+), 6 deletions(-) > > Wow chunk size larger than 4G! Normally filesystems like ext4 put data all around the disk (i.e. the used-block bitmap). However, if you use a log filesystem (like F2FS), then all the data is at the beginning of the disk. In that case, it is fairly easy to end up with a 4GiB or greater "don't care" chunk taking up most of the disk. --Sean > > But patch seems valid, so > > Reviewed-by: Heiko Schocher > > bye, > Heiko >