While debugging some issues with QEMU_STRACE I stumbled over segmentation
faults that were pretty reproducible. Turns out we tried to treat a
normal return value as errno, resulting in an access over array boundaries
for the resolution.

Fix this by hard-mapping values above valid errnos to the original value.

Signed-off-by: Alexander Graf <ag...@suse.de>
---
 linux-user/syscall.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index f227097..312aec5 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -711,6 +711,9 @@ static inline int host_to_target_errno(int err)
 
 static inline int target_to_host_errno(int err)
 {
+    if (err >= ERRNO_TABLE_SIZE) {
+        return err;
+    }
     if (target_to_host_errno_table[err])
         return target_to_host_errno_table[err];
     return err;
-- 
1.6.0.2


Reply via email to