mirror of
https://github.com/qemu/qemu.git
synced 2024-12-13 22:43:32 +08:00
linux-user pull request 20210409
Fix lock_user()/unlock_user() -----BEGIN PGP SIGNATURE----- iQJGBAABCAAwFiEEzS913cjjpNwuT1Fz8ww4vT8vvjwFAmBwUf0SHGxhdXJlbnRA dml2aWVyLmV1AAoJEPMMOL0/L748PwkP/1N86uPuXYXaQPj8a8KKPNUrIpVDojmq cOeyvIa4pRdShd2xHyEwYSIF0LmWxIFj/LlbI7lnerQvQKI9H8A5P/XYz+JVcUTD lC7pIujalkpH0mw9MrO1AzX5I0I3HidbKG/d3DWTS82JN6jLguB198SiqhrJJjq8 zGnJJIJ8t2fiNdDYGfklctWEcet7VXBcQuDrOCY5sPNcPGu6ngUyMBbJU41uVkIC 547UI3WnEgBKM2Y65or2GgVtIi5elqoirgolDcHzY3da9z/IGAR+Y6olIpGR2Bhj urCA7uNsNHab4adgGPWBRchUxXWXjc98ZOGWlJ0WVQDBIJFDI7XCiNJcWEy2hW2n RXXZHd54So+GIpw3gRbHpNYsFDtXOMSW7E3VzC0Ico0huOexu/S6SLj1V66+1TLO Cj5QW+izg1Wp9aEPybSgDBDcqpq79bfYPGfB5jLtvAmjEPhYn3uEwOta8RmZnIsG wy8LpyVGIBVMCoCw+3A2CD16GetA7HLFEzsw00EmIbm1i/RMNxKtaQo3QRX3fFMl gsmpv/YqmJNZ8DNw1P/8b64MRftRMh2CV17KwDKaVr39Y4myQVxHrJo2k9XGFIrA Ce+Fw0ddGK+DNNqhsWSe+Khka6Rsotcgw7AHuJbYl/fTD+xjazARKBP5UIsn86C0 Ih0EeYFRgYpW =PmqE -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-6.0-pull-request' into staging linux-user pull request 20210409 Fix lock_user()/unlock_user() # gpg: Signature made Fri 09 Apr 2021 14:09:17 BST # gpg: using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C # gpg: issuer "laurent@vivier.eu" # gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [full] # gpg: aka "Laurent Vivier <laurent@vivier.eu>" [full] # gpg: aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" [full] # Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F 5173 F30C 38BD 3F2F BE3C * remotes/vivier2/tags/linux-user-for-6.0-pull-request: linux-user: Use signed lengths in uaccess.c Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
285f6f57fa
@ -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
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "qemu.h"
|
||||
|
||||
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)
|
||||
{
|
||||
void *host_addr;
|
||||
|
||||
@ -24,7 +24,7 @@ void *lock_user(int type, abi_ulong guest_addr, size_t len, bool copy)
|
||||
}
|
||||
|
||||
#ifdef DEBUG_REMAP
|
||||
void unlock_user(void *host_ptr, abi_ulong guest_addr, size_t len);
|
||||
void unlock_user(void *host_ptr, abi_ulong guest_addr, ssize_t len)
|
||||
{
|
||||
void *host_ptr_conv;
|
||||
|
||||
@ -35,7 +35,7 @@ void unlock_user(void *host_ptr, abi_ulong guest_addr, size_t len);
|
||||
if (host_ptr == host_ptr_conv) {
|
||||
return;
|
||||
}
|
||||
if (len != 0) {
|
||||
if (len > 0) {
|
||||
memcpy(host_ptr_conv, host_ptr, len);
|
||||
}
|
||||
g_free(host_ptr);
|
||||
@ -48,14 +48,14 @@ void *lock_user_string(abi_ulong guest_addr)
|
||||
if (len < 0) {
|
||||
return NULL;
|
||||
}
|
||||
return lock_user(VERIFY_READ, guest_addr, (size_t)len + 1, 1);
|
||||
return lock_user(VERIFY_READ, guest_addr, len + 1, 1);
|
||||
}
|
||||
|
||||
/* copy_from_user() and copy_to_user() are usually used to copy data
|
||||
* 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_from_user(void *hptr, abi_ulong gaddr, ssize_t len)
|
||||
{
|
||||
int ret = 0;
|
||||
void *ghptr = lock_user(VERIFY_READ, gaddr, len, 1);
|
||||
@ -69,7 +69,7 @@ int copy_from_user(void *hptr, abi_ulong gaddr, size_t len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int copy_to_user(abi_ulong gaddr, void *hptr, size_t len)
|
||||
int copy_to_user(abi_ulong gaddr, void *hptr, ssize_t len)
|
||||
{
|
||||
int ret = 0;
|
||||
void *ghptr = lock_user(VERIFY_WRITE, gaddr, len, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user