diff mbox series

[PULL,20/47] linux-user: Make sure initial brk(0) is page-aligned

Message ID 20230715135317.7219-21-richard.henderson@linaro.org
State Accepted
Commit d28b3c90cfad1a7e211ae2bce36ecb9071086129
Headers show
Series [PULL,01/47] linux-user: Reformat syscall_defs.h | expand

Commit Message

Richard Henderson July 15, 2023, 1:52 p.m. UTC
From: Andreas Schwab <schwab@suse.de>

Fixes: 86f04735ac ("linux-user: Fix brk() to release pages")
Signed-off-by: Andreas Schwab <schwab@suse.de>
Message-Id: <mvmpm55qnno.fsf@suse.de>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael Tokarev July 16, 2023, 6:15 p.m. UTC | #1
15.07.2023 16:52, Richard Henderson wrote:
> From: Andreas Schwab <schwab@suse.de>
> 
> Fixes: 86f04735ac ("linux-user: Fix brk() to release pages")
> Signed-off-by: Andreas Schwab <schwab@suse.de>
> Message-Id: <mvmpm55qnno.fsf@suse.de>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

This smells like a stable-8.0 material.  Please let me know if it is not.

Thanks,

/mjt
Richard Henderson July 17, 2023, 2:42 p.m. UTC | #2
On 7/16/23 19:15, Michael Tokarev wrote:
> 15.07.2023 16:52, Richard Henderson wrote:
>> From: Andreas Schwab <schwab@suse.de>
>>
>> Fixes: 86f04735ac ("linux-user: Fix brk() to release pages")
>> Signed-off-by: Andreas Schwab <schwab@suse.de>
>> Message-Id: <mvmpm55qnno.fsf@suse.de>
>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> 
> This smells like a stable-8.0 material.  Please let me know if it is not.

Yep.


r~
Michael Tokarev July 17, 2023, 2:57 p.m. UTC | #3
17.07.2023 17:42, Richard Henderson пишет:
> On 7/16/23 19:15, Michael Tokarev wrote:
>> 15.07.2023 16:52, Richard Henderson wrote:
>>> From: Andreas Schwab <schwab@suse.de>
>>>
>>> Fixes: 86f04735ac ("linux-user: Fix brk() to release pages")
>>> Signed-off-by: Andreas Schwab <schwab@suse.de>
>>> Message-Id: <mvmpm55qnno.fsf@suse.de>
>>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>>
>> This smells like a stable-8.0 material.  Please let me know if it is not.
> 
> Yep.

FWIW, there was an attempt to fix another issue I posted about
yesterday, with libklibc-based apps on armhf, after "linux-user:
Reserve space for brk" commit, here:

   https://github.com/hdeller/qemu-hppa/commits/upx-fix

(which reverts this very commit).  But apparently it doesn't fix
that issue, libklibc-linked armhf apps still segfaults right at
startup.

This is jfyi, maybe this commit is just another temporary band-aid,
I dunno yet.  Yes it fixes real failures so it's already good.

Thanks,

/mjt
Michael Tokarev July 18, 2023, 11:51 a.m. UTC | #4
17.07.2023 17:42, Richard Henderson пишет:
> On 7/16/23 19:15, Michael Tokarev wrote:
>> 15.07.2023 16:52, Richard Henderson wrote:
>>> From: Andreas Schwab <schwab@suse.de>
>>>
>>> Fixes: 86f04735ac ("linux-user: Fix brk() to release pages")
>>> Signed-off-by: Andreas Schwab <schwab@suse.de>
>>> Message-Id: <mvmpm55qnno.fsf@suse.de>
>>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>>
>> This smells like a stable-8.0 material.  Please let me know if it is not.
> 
> Yep.

I postponed this one for now, given the patchset by Helge Deller, here
https://lists.nongnu.org/archive/html/qemu-devel/2023-07/msg03445.html
which reverts this very change as incorrect.

Thanks,

/mjt
diff mbox series

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index b78eb686d8..02d3b6c90a 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -806,7 +806,7 @@  static abi_ulong brk_page;
 
 void target_set_brk(abi_ulong new_brk)
 {
-    target_brk = new_brk;
+    target_brk = TARGET_PAGE_ALIGN(new_brk);
     brk_page = HOST_PAGE_ALIGN(target_brk);
 }