From: Tom Rini Date: Tue, 11 Sep 2018 08:26:38 -0400 Subject: [U-Boot] tools: mkimage: Ensure munmap unmaps the same length that was mapped In-Reply-To: <20180828225114.30005-1-judge.packham@gmail.com> References: <20180828225114.30005-1-judge.packham@gmail.com> Message-ID: <20180911122638.GU4980@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Wed, Aug 29, 2018 at 10:51:14AM +1200, Chris Packham wrote: > From: Mark Tomlinson > > The set_header call in kwbimage.c adds a checksum to the end of the > image in addition to setting up the header. It 'helpfully' updates the > st_size to match the fact that the file is now longer. However, mkimage > uses this length in the munmap call. This can lead to unmapping an extra > page, of perhaps required data. When this happens, a SEGV can occur. > > To prevent this from happening, the munmap call now uses the same length > that was passed to mmap. This could also have been fixed by not changing > the length in kwbimage.c, however changing it in the main file means > that other plugins will also not fall for the same trap. > > Signed-off-by: Mark Tomlinson > Signed-off-by: Chris Packham > [cp: resolve checkpatch complaints] > Tested-by: Chris Packham Applied to u-boot/master, thanks! -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: