linux-user: correct msgrcv()
PATCH 1/1 linux-user: correct msgrcv()
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 <[email protected]>
--- linux-user/syscall.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
linux-user/syscall.c +2 -2
@@ -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 ;
Signature · 1 line
1.7.10.4
Ping !
Quoted 55 lines · 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 FAILEDWITH 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 FAILEDSigned-off-by Laurent Vivier <[email protected]>--- linux-user/syscall.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)linux-user/syscall.c +2
-2@@ -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 ;
Signature · 4 lines
"Just play. Have fun. Enjoy the game." - Michael Jordan "Just play. Have fun. Enjoy the game." - Michael Jordan
Quoted 13 lines · Laurent Vivier
All parameters must be swapped before the call of
do_msgrcv().linux-user/syscall.c +1
-1@@ -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);
linux-user/syscall.c static abi_long do_ipc(unsigned int call, int first, · line 3205
Quoted 8 lines
linux-user/syscall.c +1
-1@@ -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 <[email protected]>
-- PMM
Quoted 17 lines · Peter Maydell
Quoted 16 lines · Laurent Vivier
All parameters must be swapped before the call of
do_msgrcv().linux-user/syscall.c +1
-1@@ -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 ; }
Quoted 8 lines
linux-user/syscall.c static abi_long do_ipc(unsigned int call, int first, · line 3205
Quoted 5 lines
linux-user/syscall.c +1
-1- 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 <[email protected]>
ping ?
Laurent
Signature · 2 lines
"Just play. Have fun. Enjoy the game." - Michael Jordan