[U-Boot] tools: mkimage: Ensure munmap unmaps the same length that was mapped

Tom Rini trini at konsulko.com
Tue Sep 11 12:26:38 UTC 2018


On Wed, Aug 29, 2018 at 10:51:14AM +1200, Chris Packham wrote:

> From: Mark Tomlinson <mark.tomlinson at alliedtelesis.co.nz>
> 
> 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 <mark.tomlinson at alliedtelesis.co.nz>
> Signed-off-by: Chris Packham <judge.packham at gmail.com>
> [cp: resolve checkpatch complaints]
> Tested-by: Chris Packham <judge.packham at gmail.com>

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: <http://lists.denx.de/pipermail/u-boot/attachments/20180911/60a2fd0c/attachment.sig>


More information about the U-Boot mailing list