diff options
author | Helge Deller <deller@gmx.de> | 2023-07-17 12:27:13 +0200 |
---|---|---|
committer | Michael Tokarev <mjt@tls.msk.ru> | 2023-07-31 08:52:38 +0300 |
commit | c4a4731408aca296ad88770e8a545b42e40a5d56 (patch) | |
tree | 325fd3708e5ae32b497c6e48d70547994494ddae /stubs/cmos.c | |
parent | 0102c92a1c2736fc183bd464c1f899c96ca8faea (diff) |
linux-user: Prohibit brk() to to shrink below initial heap address
Since commit 86f04735ac ("linux-user: Fix brk() to release pages") it's
possible for userspace applications to reduce their memory footprint by
calling brk() with a lower address and free up memory. Before that commit
guest heap memory was never unmapped.
But the Linux kernel prohibits to reduce brk() below the initial memory
address which is set at startup by the set_brk() function in binfmt_elf.c.
Such a range check was missed in commit 86f04735ac.
This patch adds the missing check by storing the initial brk value in
initial_target_brk and verify any new brk addresses against that value.
Tested with the i386 upx binary from
https://github.com/upx/upx/releases/download/v4.0.2/upx-4.0.2-i386_linux.tar.xz
Signed-off-by: Helge Deller <deller@gmx.de>
Tested-by: "Markus F.X.J. Oberhumer" <markus@oberhumer.com>
Fixes: 86f04735ac ("linux-user: Fix brk() to release pages")
Cc: qemu-stable@nongnu.org
Buglink: https://github.com/upx/upx/issues/683
(cherry picked from commit dfe49864afb06e7e452a4366051697bc4fcfc1a5)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'stubs/cmos.c')
0 files changed, 0 insertions, 0 deletions