* [Qemu-devel] [PATCH] linux-user: correct msgrcv()
@ 2012-12-20 21:00 Laurent Vivier
2013-01-01 23:10 ` Laurent Vivier
2013-01-02 0:03 ` Peter Maydell
0 siblings, 2 replies; 4+ messages in thread
From: Laurent Vivier @ 2012-12-20 21:00 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Laurent Vivier
All parameters must be swapped before the call of do_msgrcv().
Allow faked (debian fakeroot daemon) to work properly.
WITHOUT this patch:
$ faked-sysv --foreground --debug
using 1723744788 as msg key
msg_key=1723744788
1723744788:431
FAKEROOT: msg=131072, key=1723744788
FAKEROOT: r=-1, received message type=-150996052, message=-160219330
FAKEROOT, get_msg: Bad address
r=14, EINTR=4
fakeroot: clearing up message queues and semaphores, signal=-1
fakeroot: database save FAILED
WITH this patch:
$ faked-sysv --foreground --debug
using 1569385744 as msg key
msg_key=1569385744
1569385744:424
FAKEROOT: msg=0, key=1569385744
^C
fakeroot: clearing up message queues and semaphores, signal=2
fakeroot: database save FAILED
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/syscall.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 7bab006..78cb764 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2901,7 +2901,7 @@ static inline abi_long do_msgrcv(int msqid, abi_long msgp,
return -TARGET_EFAULT;
host_mb = g_malloc(msgsz+sizeof(long));
- ret = get_errno(msgrcv(msqid, host_mb, msgsz, tswapal(msgtyp), msgflg));
+ ret = get_errno(msgrcv(msqid, host_mb, msgsz, msgtyp, msgflg));
if (ret > 0) {
abi_ulong target_mtext_addr = msgp + sizeof(abi_ulong);
@@ -3199,7 +3199,7 @@ static abi_long do_ipc(unsigned int call, int first,
break;
}
- ret = do_msgrcv(first, tmp->msgp, second, tmp->msgtyp, third);
+ ret = do_msgrcv(first, tswapal(tmp->msgp), second, tswapal(tmp->msgtyp), third);
unlock_user_struct(tmp, ptr, 0);
break;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: correct msgrcv()
2012-12-20 21:00 [Qemu-devel] [PATCH] linux-user: correct msgrcv() Laurent Vivier
@ 2013-01-01 23:10 ` Laurent Vivier
2013-01-02 0:03 ` Peter Maydell
1 sibling, 0 replies; 4+ messages in thread
From: Laurent Vivier @ 2013-01-01 23:10 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio
Ping !
Le jeudi 20 décembre 2012 à 22:00 +0100, Laurent Vivier a écrit :
> All parameters must be swapped before the call of do_msgrcv().
>
> Allow faked (debian fakeroot daemon) to work properly.
>
> WITHOUT this patch:
>
> $ faked-sysv --foreground --debug
> using 1723744788 as msg key
> msg_key=1723744788
> 1723744788:431
> FAKEROOT: msg=131072, key=1723744788
> FAKEROOT: r=-1, received message type=-150996052, message=-160219330
> FAKEROOT, get_msg: Bad address
> r=14, EINTR=4
> fakeroot: clearing up message queues and semaphores, signal=-1
> fakeroot: database save FAILED
>
> WITH this patch:
>
> $ faked-sysv --foreground --debug
> using 1569385744 as msg key
> msg_key=1569385744
> 1569385744:424
> FAKEROOT: msg=0, key=1569385744
> ^C
> fakeroot: clearing up message queues and semaphores, signal=2
> fakeroot: database save FAILED
>
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
> linux-user/syscall.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 7bab006..78cb764 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -2901,7 +2901,7 @@ static inline abi_long do_msgrcv(int msqid, abi_long msgp,
> return -TARGET_EFAULT;
>
> host_mb = g_malloc(msgsz+sizeof(long));
> - ret = get_errno(msgrcv(msqid, host_mb, msgsz, tswapal(msgtyp), msgflg));
> + ret = get_errno(msgrcv(msqid, host_mb, msgsz, msgtyp, msgflg));
>
> if (ret > 0) {
> abi_ulong target_mtext_addr = msgp + sizeof(abi_ulong);
> @@ -3199,7 +3199,7 @@ static abi_long do_ipc(unsigned int call, int first,
> break;
> }
>
> - ret = do_msgrcv(first, tmp->msgp, second, tmp->msgtyp, third);
> + ret = do_msgrcv(first, tswapal(tmp->msgp), second, tswapal(tmp->msgtyp), third);
>
> unlock_user_struct(tmp, ptr, 0);
> break;
--
"Just play. Have fun. Enjoy the game."
- Michael Jordan
"Just play. Have fun. Enjoy the game."
- Michael Jordan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: correct msgrcv()
2012-12-20 21:00 [Qemu-devel] [PATCH] linux-user: correct msgrcv() Laurent Vivier
2013-01-01 23:10 ` Laurent Vivier
@ 2013-01-02 0:03 ` Peter Maydell
2013-01-19 23:29 ` Laurent Vivier
1 sibling, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2013-01-02 0:03 UTC (permalink / raw)
To: Laurent Vivier; +Cc: Riku Voipio, qemu-devel
On 20 December 2012 21:00, Laurent Vivier <laurent@vivier.eu> wrote:
> All parameters must be swapped before the call of do_msgrcv().
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -2901,7 +2901,7 @@ static inline abi_long do_msgrcv(int msqid, abi_long msgp,
> return -TARGET_EFAULT;
>
> host_mb = g_malloc(msgsz+sizeof(long));
> - ret = get_errno(msgrcv(msqid, host_mb, msgsz, tswapal(msgtyp), msgflg));
> + ret = get_errno(msgrcv(msqid, host_mb, msgsz, msgtyp, msgflg));
>
> if (ret > 0) {
> abi_ulong target_mtext_addr = msgp + sizeof(abi_ulong);
> @@ -3199,7 +3199,7 @@ static abi_long do_ipc(unsigned int call, int first,
> break;
> }
>
> - ret = do_msgrcv(first, tmp->msgp, second, tmp->msgtyp, third);
> + ret = do_msgrcv(first, tswapal(tmp->msgp), second, tswapal(tmp->msgtyp), third);
>
> unlock_user_struct(tmp, ptr, 0);
> break;
Untested but looks right.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: correct msgrcv()
2013-01-02 0:03 ` Peter Maydell
@ 2013-01-19 23:29 ` Laurent Vivier
0 siblings, 0 replies; 4+ messages in thread
From: Laurent Vivier @ 2013-01-19 23:29 UTC (permalink / raw)
To: Peter Maydell; +Cc: Riku Voipio, qemu-devel
Le mercredi 02 janvier 2013 à 00:03 +0000, Peter Maydell a écrit :
> On 20 December 2012 21:00, Laurent Vivier <laurent@vivier.eu> wrote:
> > All parameters must be swapped before the call of do_msgrcv().
> > --- a/linux-user/syscall.c
> > +++ b/linux-user/syscall.c
> > @@ -2901,7 +2901,7 @@ static inline abi_long do_msgrcv(int msqid, abi_long msgp,
> > return -TARGET_EFAULT;
> >
> > host_mb = g_malloc(msgsz+sizeof(long));
> > - ret = get_errno(msgrcv(msqid, host_mb, msgsz, tswapal(msgtyp), msgflg));
> > + ret = get_errno(msgrcv(msqid, host_mb, msgsz, msgtyp, msgflg));
> >
> > if (ret > 0) {
> > abi_ulong target_mtext_addr = msgp + sizeof(abi_ulong);
> > @@ -3199,7 +3199,7 @@ static abi_long do_ipc(unsigned int call, int first,
> > break;
> > }
> >
> > - ret = do_msgrcv(first, tmp->msgp, second, tmp->msgtyp, third);
> > + ret = do_msgrcv(first, tswapal(tmp->msgp), second, tswapal(tmp->msgtyp), third);
> >
> > unlock_user_struct(tmp, ptr, 0);
> > break;
>
> Untested but looks right.
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
ping ?
Laurent
--
"Just play. Have fun. Enjoy the game."
- Michael Jordan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-01-19 23:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-20 21:00 [Qemu-devel] [PATCH] linux-user: correct msgrcv() Laurent Vivier
2013-01-01 23:10 ` Laurent Vivier
2013-01-02 0:03 ` Peter Maydell
2013-01-19 23:29 ` Laurent Vivier
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).