[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 14/14] linux-user: Fix 'utimensat()' implementation
From: |
Laurent Vivier |
Subject: |
[PULL 14/14] linux-user: Fix 'utimensat()' implementation |
Date: |
Thu, 13 Aug 2020 08:49:23 +0200 |
From: Filip Bozuta <Filip.Bozuta@syrmia.com>
Implementation of syscall 'utimensat()' in 'syscall.c' uses functions
target_to_host/host_to_target_timespec() to convert values of
'struct timespec' between host and target. However, the implementation
doesn't check whether the conversion succeeds and thus can cause an
inappropriate error or succeed unappropriately instead of setting errno
EFAULT ('Bad address') which is supposed to be set in these cases.
This was confirmed with the LTP test for utimensat ('testcases/utimensat')
which fails for test cases when the errno EFAULT is expected. After changes
from this patch, the test passes for all test cases.
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811113101.6636-1-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/syscall.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 10dd53bf999b..96ae942909ab 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -11922,8 +11922,13 @@ static abi_long do_syscall1(void *cpu_env, int num,
abi_long arg1,
if (!arg3) {
tsp = NULL;
} else {
- target_to_host_timespec(ts, arg3);
- target_to_host_timespec(ts+1, arg3+sizeof(struct
target_timespec));
+ if (target_to_host_timespec(ts, arg3)) {
+ return -TARGET_EFAULT;
+ }
+ if (target_to_host_timespec(ts + 1, arg3 +
+ sizeof(struct target_timespec))) {
+ return -TARGET_EFAULT;
+ }
tsp = ts;
}
if (!arg2)
--
2.26.2
- [PULL 02/14] linux-user: Validate mmap/mprotect prot value, (continued)
- [PULL 02/14] linux-user: Validate mmap/mprotect prot value, Laurent Vivier, 2020/08/13
- [PULL 03/14] linux-user: Adjust guest page protection for the host, Laurent Vivier, 2020/08/13
- [PULL 07/14] linux-user: Add support for a group of btrfs ioctls used for snapshots, Laurent Vivier, 2020/08/13
- [PULL 06/14] linux-user: Add support for a group of btrfs ioctls used for subvolumes, Laurent Vivier, 2020/08/13
- [PULL 05/14] linux-user: Add support for a group of 2038 safe syscalls, Laurent Vivier, 2020/08/13
- [PULL 08/14] linux-user: Add support for btrfs ioctls used to manipulate with devices, Laurent Vivier, 2020/08/13
- [PULL 04/14] linux-user: Modify 'target_to_host/host_to_target_itimerspec()', Laurent Vivier, 2020/08/13
- [PULL 09/14] linux-user: Add support for btrfs ioctls used to get/set features, Laurent Vivier, 2020/08/13
- [PULL 13/14] linux-user: Add support for btrfs ioctls used to scrub a filesystem, Laurent Vivier, 2020/08/13
- [PULL 10/14] linux-user: Add support for a group of btrfs inode ioctls, Laurent Vivier, 2020/08/13
- [PULL 14/14] linux-user: Fix 'utimensat()' implementation,
Laurent Vivier <=
- [PULL 11/14] linux-user: Add support for two btrfs ioctls used for subvolume, Laurent Vivier, 2020/08/13
- [PULL 12/14] linux-user: Add support for btrfs ioctls used to manage quota, Laurent Vivier, 2020/08/13
- Re: [PULL 00/14] Linux user for 5.2 patches, Peter Maydell, 2020/08/21