From: Ulrich Hecht <uli@suse.de>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 2/4] 64-bit clean socketcall syscall
Date: Fri, 3 Jul 2009 17:09:28 +0200 [thread overview]
Message-ID: <1246633770-13404-4-git-send-email-uli@suse.de> (raw)
In-Reply-To: <1246633770-13404-3-git-send-email-uli@suse.de>
makes socketcall 64-bit clean so it works on 64-bit big-endian systems
Signed-off-by: Ulrich Hecht <uli@suse.de>
---
linux-user/syscall.c | 130 +++++++++++++++++++++++++-------------------------
1 files changed, 65 insertions(+), 65 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 57bb9a7..e541b0d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1751,11 +1751,11 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
switch(num) {
case SOCKOP_socket:
{
- int domain, type, protocol;
+ abi_ulong domain, type, protocol;
- if (get_user_s32(domain, vptr)
- || get_user_s32(type, vptr + n)
- || get_user_s32(protocol, vptr + 2 * n))
+ if (get_user_ual(domain, vptr)
+ || get_user_ual(type, vptr + n)
+ || get_user_ual(protocol, vptr + 2 * n))
return -TARGET_EFAULT;
ret = do_socket(domain, type, protocol);
@@ -1763,13 +1763,13 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
break;
case SOCKOP_bind:
{
- int sockfd;
+ abi_ulong sockfd;
abi_ulong target_addr;
socklen_t addrlen;
- if (get_user_s32(sockfd, vptr)
+ if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + n)
- || get_user_u32(addrlen, vptr + 2 * n))
+ || get_user_ual(addrlen, vptr + 2 * n))
return -TARGET_EFAULT;
ret = do_bind(sockfd, target_addr, addrlen);
@@ -1777,13 +1777,13 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
break;
case SOCKOP_connect:
{
- int sockfd;
+ abi_ulong sockfd;
abi_ulong target_addr;
socklen_t addrlen;
- if (get_user_s32(sockfd, vptr)
+ if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + n)
- || get_user_u32(addrlen, vptr + 2 * n))
+ || get_user_ual(addrlen, vptr + 2 * n))
return -TARGET_EFAULT;
ret = do_connect(sockfd, target_addr, addrlen);
@@ -1791,10 +1791,10 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
break;
case SOCKOP_listen:
{
- int sockfd, backlog;
+ abi_ulong sockfd, backlog;
- if (get_user_s32(sockfd, vptr)
- || get_user_s32(backlog, vptr + n))
+ if (get_user_ual(sockfd, vptr)
+ || get_user_ual(backlog, vptr + n))
return -TARGET_EFAULT;
ret = get_errno(listen(sockfd, backlog));
@@ -1802,12 +1802,12 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
break;
case SOCKOP_accept:
{
- int sockfd;
+ abi_ulong sockfd;
abi_ulong target_addr, target_addrlen;
- if (get_user_s32(sockfd, vptr)
+ if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + n)
- || get_user_u32(target_addrlen, vptr + 2 * n))
+ || get_user_ual(target_addrlen, vptr + 2 * n))
return -TARGET_EFAULT;
ret = do_accept(sockfd, target_addr, target_addrlen);
@@ -1815,12 +1815,12 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
break;
case SOCKOP_getsockname:
{
- int sockfd;
+ abi_ulong sockfd;
abi_ulong target_addr, target_addrlen;
- if (get_user_s32(sockfd, vptr)
+ if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + n)
- || get_user_u32(target_addrlen, vptr + 2 * n))
+ || get_user_ual(target_addrlen, vptr + 2 * n))
return -TARGET_EFAULT;
ret = do_getsockname(sockfd, target_addr, target_addrlen);
@@ -1828,12 +1828,12 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
break;
case SOCKOP_getpeername:
{
- int sockfd;
+ abi_ulong sockfd;
abi_ulong target_addr, target_addrlen;
- if (get_user_s32(sockfd, vptr)
+ if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + n)
- || get_user_u32(target_addrlen, vptr + 2 * n))
+ || get_user_ual(target_addrlen, vptr + 2 * n))
return -TARGET_EFAULT;
ret = do_getpeername(sockfd, target_addr, target_addrlen);
@@ -1841,12 +1841,12 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
break;
case SOCKOP_socketpair:
{
- int domain, type, protocol;
+ abi_ulong domain, type, protocol;
abi_ulong tab;
- if (get_user_s32(domain, vptr)
- || get_user_s32(type, vptr + n)
- || get_user_s32(protocol, vptr + 2 * n)
+ if (get_user_ual(domain, vptr)
+ || get_user_ual(type, vptr + n)
+ || get_user_ual(protocol, vptr + 2 * n)
|| get_user_ual(tab, vptr + 3 * n))
return -TARGET_EFAULT;
@@ -1855,15 +1855,15 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
break;
case SOCKOP_send:
{
- int sockfd;
+ abi_ulong sockfd;
abi_ulong msg;
size_t len;
- int flags;
+ abi_ulong flags;
- if (get_user_s32(sockfd, vptr)
+ if (get_user_ual(sockfd, vptr)
|| get_user_ual(msg, vptr + n)
|| get_user_ual(len, vptr + 2 * n)
- || get_user_s32(flags, vptr + 3 * n))
+ || get_user_ual(flags, vptr + 3 * n))
return -TARGET_EFAULT;
ret = do_sendto(sockfd, msg, len, flags, 0, 0);
@@ -1871,15 +1871,15 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
break;
case SOCKOP_recv:
{
- int sockfd;
+ abi_ulong sockfd;
abi_ulong msg;
size_t len;
- int flags;
+ abi_ulong flags;
- if (get_user_s32(sockfd, vptr)
+ if (get_user_ual(sockfd, vptr)
|| get_user_ual(msg, vptr + n)
|| get_user_ual(len, vptr + 2 * n)
- || get_user_s32(flags, vptr + 3 * n))
+ || get_user_ual(flags, vptr + 3 * n))
return -TARGET_EFAULT;
ret = do_recvfrom(sockfd, msg, len, flags, 0, 0);
@@ -1887,19 +1887,19 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
break;
case SOCKOP_sendto:
{
- int sockfd;
+ abi_ulong sockfd;
abi_ulong msg;
size_t len;
- int flags;
+ abi_ulong flags;
abi_ulong addr;
socklen_t addrlen;
- if (get_user_s32(sockfd, vptr)
+ if (get_user_ual(sockfd, vptr)
|| get_user_ual(msg, vptr + n)
|| get_user_ual(len, vptr + 2 * n)
- || get_user_s32(flags, vptr + 3 * n)
+ || get_user_ual(flags, vptr + 3 * n)
|| get_user_ual(addr, vptr + 4 * n)
- || get_user_u32(addrlen, vptr + 5 * n))
+ || get_user_ual(addrlen, vptr + 5 * n))
return -TARGET_EFAULT;
ret = do_sendto(sockfd, msg, len, flags, addr, addrlen);
@@ -1907,19 +1907,19 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
break;
case SOCKOP_recvfrom:
{
- int sockfd;
+ abi_ulong sockfd;
abi_ulong msg;
size_t len;
- int flags;
+ abi_ulong flags;
abi_ulong addr;
socklen_t addrlen;
- if (get_user_s32(sockfd, vptr)
+ if (get_user_ual(sockfd, vptr)
|| get_user_ual(msg, vptr + n)
|| get_user_ual(len, vptr + 2 * n)
- || get_user_s32(flags, vptr + 3 * n)
+ || get_user_ual(flags, vptr + 3 * n)
|| get_user_ual(addr, vptr + 4 * n)
- || get_user_u32(addrlen, vptr + 5 * n))
+ || get_user_ual(addrlen, vptr + 5 * n))
return -TARGET_EFAULT;
ret = do_recvfrom(sockfd, msg, len, flags, addr, addrlen);
@@ -1927,10 +1927,10 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
break;
case SOCKOP_shutdown:
{
- int sockfd, how;
+ abi_ulong sockfd, how;
- if (get_user_s32(sockfd, vptr)
- || get_user_s32(how, vptr + n))
+ if (get_user_ual(sockfd, vptr)
+ || get_user_ual(how, vptr + n))
return -TARGET_EFAULT;
ret = get_errno(shutdown(sockfd, how));
@@ -1939,13 +1939,13 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
case SOCKOP_sendmsg:
case SOCKOP_recvmsg:
{
- int fd;
+ abi_ulong fd;
abi_ulong target_msg;
- int flags;
+ abi_ulong flags;
- if (get_user_s32(fd, vptr)
+ if (get_user_ual(fd, vptr)
|| get_user_ual(target_msg, vptr + n)
- || get_user_s32(flags, vptr + 2 * n))
+ || get_user_ual(flags, vptr + 2 * n))
return -TARGET_EFAULT;
ret = do_sendrecvmsg(fd, target_msg, flags,
@@ -1954,17 +1954,17 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
break;
case SOCKOP_setsockopt:
{
- int sockfd;
- int level;
- int optname;
+ abi_ulong sockfd;
+ abi_ulong level;
+ abi_ulong optname;
abi_ulong optval;
socklen_t optlen;
- if (get_user_s32(sockfd, vptr)
- || get_user_s32(level, vptr + n)
- || get_user_s32(optname, vptr + 2 * n)
+ if (get_user_ual(sockfd, vptr)
+ || get_user_ual(level, vptr + n)
+ || get_user_ual(optname, vptr + 2 * n)
|| get_user_ual(optval, vptr + 3 * n)
- || get_user_u32(optlen, vptr + 4 * n))
+ || get_user_ual(optlen, vptr + 4 * n))
return -TARGET_EFAULT;
ret = do_setsockopt(sockfd, level, optname, optval, optlen);
@@ -1972,17 +1972,17 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
break;
case SOCKOP_getsockopt:
{
- int sockfd;
- int level;
- int optname;
+ abi_ulong sockfd;
+ abi_ulong level;
+ abi_ulong optname;
abi_ulong optval;
socklen_t optlen;
- if (get_user_s32(sockfd, vptr)
- || get_user_s32(level, vptr + n)
- || get_user_s32(optname, vptr + 2 * n)
+ if (get_user_ual(sockfd, vptr)
+ || get_user_ual(level, vptr + n)
+ || get_user_ual(optname, vptr + 2 * n)
|| get_user_ual(optval, vptr + 3 * n)
- || get_user_u32(optlen, vptr + 4 * n))
+ || get_user_ual(optlen, vptr + 4 * n))
return -TARGET_EFAULT;
ret = do_getsockopt(sockfd, level, optname, optval, optlen);
--
1.6.2.1
next prev parent reply other threads:[~2009-07-03 15:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-03 15:09 [Qemu-devel] [PATCH 0/4] linux-user syscall bugs Ulrich Hecht
2009-07-03 15:09 ` [Qemu-devel] [PATCH 1/4] pipe argument should not be signed Ulrich Hecht
2009-07-03 15:09 ` [Qemu-devel] [PATCH] warnings in net.c Ulrich Hecht
2009-07-03 15:09 ` Ulrich Hecht [this message]
2009-07-03 15:09 ` [Qemu-devel] [PATCH 3/4] wrap path for access syscall Ulrich Hecht
2009-07-03 15:09 ` [Qemu-devel] [PATCH 4/4] getrlimit conversion mix-up Ulrich Hecht
2009-07-08 19:18 ` [Qemu-devel] " Riku Voipio
2009-07-03 15:10 ` [Qemu-devel] Re: [PATCH] warnings in net.c Ulrich Hecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1246633770-13404-4-git-send-email-uli@suse.de \
--to=uli@suse.de \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).