linux-user: pass sockaddr from host to target
PATCH v2 1/3 linux-user: pass sockaddr from host to target
This patch pass sockaddr from host to target.
--- linux-user/syscall.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)
linux-user/syscall.c +9 -1
@@ -1873,8 +1873,16 @@ static abi_long do_sendrecvmsg(int fd, abi_ulong target_msg,if (!is_error (ret)) { len = ret; ret =host_to_target_cmsg (msgp, &msg); -if (!is_error (ret)) +if (!is_error (ret)) { + msgp->msg_namelen = msg.msg_namelen; + ret =host_to_target_sockaddr (tswapal (msgp->msg_name), + msg.msg_name, msg.msg_namelen); +if (ret) { +qemu_log ("Failed to pass sockaddr to target guest" ); +return ret; + } ret = len; + } } }unlock_iovec (vec, target_vec, count, !send);
Signature · 1 line
1.7.8.6
Quoted 12 lines · Jing Huang
This patch pass sockaddr from host to target.
Signed-off-by Jing Huang <[email protected]>--- linux-user/syscall.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)linux-user/syscall.c +0
-0
linux-user/syscall.c static abi_long do_sendrecvmsg(int fd, abi_ulong target_msg, · line 1877
Quoted 6 lines
linux-user/syscall.c +2
-1@@ -1873,8 +1873,16 @@ static abi_long do_sendrecvmsg(int fd, abi_ulong target_msg,if (!is_error (ret)) { len = ret; ret =host_to_target_cmsg (msgp, &msg); -if (!is_error (ret)) +if (!is_error (ret)) { + msgp->msg_namelen = msg.msg_namelen;
You need to swap msg_namelen using tswap32().
linux-user/syscall.c static abi_long do_sendrecvmsg(int fd, abi_ulong target_msg, · line 1879
Quoted 2 lines
linux-user/syscall.c +2
-0+ ret =host_to_target_sockaddr (tswapal (msgp->msg_name), + msg.msg_name, msg.msg_namelen);
host_to_target_sockaddr assumes msg.msg_name isn't NULL, so you need to enclose this in an if() to avoid that.
linux-user/syscall.c static abi_long do_sendrecvmsg(int fd, abi_ulong target_msg, · line 1881
Quoted 2 lines
linux-user/syscall.c +2
-0+if (ret) { +qemu_log ("Failed to pass sockaddr to target guest" );
Don't print any logging here -- we should only be logging anything for (a) unimplemented features or (b) debug tracing which is guarded by #ifdef DEBUG.
linux-user/syscall.c static abi_long do_sendrecvmsg(int fd, abi_ulong target_msg, · line 1882
Quoted 1 line
linux-user/syscall.c +1
-0+return ret;
Returning here bypasses the unlocking of the iovec and user struct.
linux-user/syscall.c static abi_long do_sendrecvmsg(int fd, abi_ulong target_msg, · line 1884
Quoted 2 lines
linux-user/syscall.c +1
-0+ } ret = len;
...the above two points mean you wanted
if (!is_error(ret)) {
ret = len;}
here.
linux-user/syscall.c static abi_long do_sendrecvmsg(int fd, abi_ulong target_msg, · line 1885
Quoted 1 line
linux-user/syscall.c +1
-0+ }
-- PMM