aboutsummaryrefslogtreecommitdiff
path: root/linux-user/qemu.h
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2021-03-15 14:40:04 -0600
committerLaurent Vivier <laurent@vivier.eu>2021-04-07 18:55:27 +0200
commit360f0abdc51652b06a3718ed43a8688562e69ca4 (patch)
tree1cabb7f09d56175334301eca8ae26a7b888b1c56 /linux-user/qemu.h
parentd0d3dd401b70168a353450e031727affee828527 (diff)
linux-user: Use signed lengths in uaccess.c
Partially revert 09f679b62dff, but only for the length arguments. Instead of reverting to long, use ssize_t. Reinstate the > 0 check in unlock_user. Fixes: 09f679b62dff Reported-by: Coverity (CID 1446711) Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20210315204004.2025219-1-richard.henderson@linaro.org> [lv: remove superfluous semicolon] Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Diffstat (limited to 'linux-user/qemu.h')
-rw-r--r--linux-user/qemu.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index 52c981710b..74e06e7121 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -627,8 +627,8 @@ static inline bool access_ok(CPUState *cpu, int type,
* buffers between the target and host. These internally perform
* locking/unlocking of the memory.
*/
-int copy_from_user(void *hptr, abi_ulong gaddr, size_t len);
-int copy_to_user(abi_ulong gaddr, void *hptr, size_t len);
+int copy_from_user(void *hptr, abi_ulong gaddr, ssize_t len);
+int copy_to_user(abi_ulong gaddr, void *hptr, ssize_t len);
/* Functions for accessing guest memory. The tget and tput functions
read/write single values, byteswapping as necessary. The lock_user function
@@ -638,16 +638,19 @@ int copy_to_user(abi_ulong gaddr, void *hptr, size_t len);
/* Lock an area of guest memory into the host. If copy is true then the
host area will have the same contents as the guest. */
-void *lock_user(int type, abi_ulong guest_addr, size_t len, bool copy);
+void *lock_user(int type, abi_ulong guest_addr, ssize_t len, bool copy);
/* Unlock an area of guest memory. The first LEN bytes must be
flushed back to guest memory. host_ptr = NULL is explicitly
allowed and does nothing. */
#ifndef DEBUG_REMAP
-static inline void unlock_user(void *host_ptr, abi_ulong guest_addr, size_t len)
-{ }
+static inline void unlock_user(void *host_ptr, abi_ulong guest_addr,
+ ssize_t len)
+{
+ /* no-op */
+}
#else
-void unlock_user(void *host_ptr, abi_ulong guest_addr, long len);
+void unlock_user(void *host_ptr, abi_ulong guest_addr, ssize_t len);
#endif
/* Return the length of a string in target memory or -TARGET_EFAULT if