[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[qemu-xen master] linux-user: Fix syscall rt_sigtimedwait() implementation



commit 4d213001b356c4a24c05afbc72f4860088900627
Author:     Filip Bozuta <Filip.Bozuta@xxxxxxxxxx>
AuthorDate: Fri Jul 24 20:16:51 2020 +0200
Commit:     Laurent Vivier <laurent@xxxxxxxxx>
CommitDate: Mon Jul 27 22:04:07 2020 +0200

    linux-user: Fix syscall rt_sigtimedwait() implementation
    
    Implementation of 'rt_sigtimedwait()' in 'syscall.c' uses the
    function 'target_to_host_timespec()' to transfer the value of
    'struct timespec' from target to host. However, the implementation
    doesn't check whether this conversion succeeds and thus can cause
    an unaproppriate error instead of the 'EFAULT (Bad address)' which
    is supposed to be set if the conversion from target to host fails.
    
    This was confirmed with the LTP test for rt_sigtimedwait:
    "/testcases/kernel/syscalls/rt_sigtimedwait/rt_sigtimedwait01.c"
    which causes an unapropriate error in test case "test_bad_adress3"
    which is run with a bad adress for the 'struct timespec' argument:
    
    FAIL: test_bad_address3 (349): Unexpected failure: EAGAIN/EWOULDBLOCK (11)
    
    The test fails with an unexptected errno 'EAGAIN/EWOULDBLOCK' instead
    of the expected EFAULT.
    
    After the changes from this patch, the test case is executed successfully
    along with the other LTP test cases for 'rt_sigtimedwait()':
    
    PASS: test_bad_address3 (349): Test passed
    
    Signed-off-by: Filip Bozuta <Filip.Bozuta@xxxxxxxxxx>
    Reviewed-by: Laurent Vivier <laurent@xxxxxxxxx>
    Message-Id: <20200724181651.167819-1-Filip.Bozuta@xxxxxxxxxx>
    Signed-off-by: Laurent Vivier <laurent@xxxxxxxxx>
---
 linux-user/syscall.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index f5c4f6b95d..c1ebf7b8f3 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8868,7 +8868,9 @@ static abi_long do_syscall1(void *cpu_env, int num, 
abi_long arg1,
             unlock_user(p, arg1, 0);
             if (arg3) {
                 puts = &uts;
-                target_to_host_timespec(puts, arg3);
+                if (target_to_host_timespec(puts, arg3)) {
+                    return -TARGET_EFAULT;
+                }
             } else {
                 puts = NULL;
             }
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.