* [PATCH] linux-user: fix Coverity CID 1464101
@ 2021-11-21 15:17 Laurent Vivier
2021-11-21 15:51 ` Richard Henderson
2021-11-22 8:16 ` Laurent Vivier
0 siblings, 2 replies; 3+ messages in thread
From: Laurent Vivier @ 2021-11-21 15:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, richard.henderson, Laurent Vivier
target_mmap() can fail and return -1, but we don't check for that and
instead assume it's always valid.
Fixes: db2af69d6ba8 ("linux-user: Add infrastructure for a signal trampoline page")
Cc: richard.henderson@linaro.org
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/elfload.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 5da8c02d0822..767f54c76dc5 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -3254,9 +3254,13 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info)
* Otherwise, allocate a private page to hold them.
*/
if (TARGET_ARCH_HAS_SIGTRAMP_PAGE) {
- abi_ulong tramp_page = target_mmap(0, TARGET_PAGE_SIZE,
- PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANON, -1, 0);
+ abi_long tramp_page = target_mmap(0, TARGET_PAGE_SIZE,
+ PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANON, -1, 0);
+ if (tramp_page == -1) {
+ return -errno;
+ }
+
setup_sigtramp(tramp_page);
target_mprotect(tramp_page, TARGET_PAGE_SIZE, PROT_READ | PROT_EXEC);
}
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] linux-user: fix Coverity CID 1464101
2021-11-21 15:17 [PATCH] linux-user: fix Coverity CID 1464101 Laurent Vivier
@ 2021-11-21 15:51 ` Richard Henderson
2021-11-22 8:16 ` Laurent Vivier
1 sibling, 0 replies; 3+ messages in thread
From: Richard Henderson @ 2021-11-21 15:51 UTC (permalink / raw)
To: Laurent Vivier, qemu-devel; +Cc: Peter Maydell
On 11/21/21 4:17 PM, Laurent Vivier wrote:
> target_mmap() can fail and return -1, but we don't check for that and
> instead assume it's always valid.
>
> Fixes: db2af69d6ba8 ("linux-user: Add infrastructure for a signal trampoline page")
> Cc: richard.henderson@linaro.org
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
> linux-user/elfload.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
>
> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
> index 5da8c02d0822..767f54c76dc5 100644
> --- a/linux-user/elfload.c
> +++ b/linux-user/elfload.c
> @@ -3254,9 +3254,13 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info)
> * Otherwise, allocate a private page to hold them.
> */
> if (TARGET_ARCH_HAS_SIGTRAMP_PAGE) {
> - abi_ulong tramp_page = target_mmap(0, TARGET_PAGE_SIZE,
> - PROT_READ | PROT_WRITE,
> - MAP_PRIVATE | MAP_ANON, -1, 0);
> + abi_long tramp_page = target_mmap(0, TARGET_PAGE_SIZE,
> + PROT_READ | PROT_WRITE,
> + MAP_PRIVATE | MAP_ANON, -1, 0);
> + if (tramp_page == -1) {
> + return -errno;
> + }
> +
> setup_sigtramp(tramp_page);
> target_mprotect(tramp_page, TARGET_PAGE_SIZE, PROT_READ | PROT_EXEC);
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] linux-user: fix Coverity CID 1464101
2021-11-21 15:17 [PATCH] linux-user: fix Coverity CID 1464101 Laurent Vivier
2021-11-21 15:51 ` Richard Henderson
@ 2021-11-22 8:16 ` Laurent Vivier
1 sibling, 0 replies; 3+ messages in thread
From: Laurent Vivier @ 2021-11-22 8:16 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, richard.henderson
Le 21/11/2021 à 16:17, Laurent Vivier a écrit :
> target_mmap() can fail and return -1, but we don't check for that and
> instead assume it's always valid.
>
> Fixes: db2af69d6ba8 ("linux-user: Add infrastructure for a signal trampoline page")
> Cc: richard.henderson@linaro.org
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
> linux-user/elfload.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
> index 5da8c02d0822..767f54c76dc5 100644
> --- a/linux-user/elfload.c
> +++ b/linux-user/elfload.c
> @@ -3254,9 +3254,13 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info)
> * Otherwise, allocate a private page to hold them.
> */
> if (TARGET_ARCH_HAS_SIGTRAMP_PAGE) {
> - abi_ulong tramp_page = target_mmap(0, TARGET_PAGE_SIZE,
> - PROT_READ | PROT_WRITE,
> - MAP_PRIVATE | MAP_ANON, -1, 0);
> + abi_long tramp_page = target_mmap(0, TARGET_PAGE_SIZE,
> + PROT_READ | PROT_WRITE,
> + MAP_PRIVATE | MAP_ANON, -1, 0);
> + if (tramp_page == -1) {
> + return -errno;
> + }
> +
> setup_sigtramp(tramp_page);
> target_mprotect(tramp_page, TARGET_PAGE_SIZE, PROT_READ | PROT_EXEC);
> }
>
Applied to my linux-user-for-6.2 branch.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-22 8:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-21 15:17 [PATCH] linux-user: fix Coverity CID 1464101 Laurent Vivier
2021-11-21 15:51 ` Richard Henderson
2021-11-22 8:16 ` Laurent Vivier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).