diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2022-08-28 13:10:35 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2022-08-28 13:10:35 +0200 |
commit | 4f82ae66628a517585d6bef9465662a45481d024 (patch) | |
tree | bfe4affbca50e455b59925b007b19ea096bfb99f | |
parent | 30c93547cd14db1ae44ea9e32bf36a2c2b152c07 (diff) | |
download | gnumach-4f82ae66628a517585d6bef9465662a45481d024.tar.gz gnumach-4f82ae66628a517585d6bef9465662a45481d024.tar.bz2 gnumach-4f82ae66628a517585d6bef9465662a45481d024.zip |
copyinmsg: Set msgh_size inside copyinmsg rather than the caller
In the 32/64 conversion case it is copyinmsg that will know the
eventual size.
-rw-r--r-- | i386/i386/i386asm.sym | 2 | ||||
-rw-r--r-- | i386/i386/locore.S | 4 | ||||
-rw-r--r-- | include/mach/message.h | 2 | ||||
-rw-r--r-- | ipc/ipc_kmsg.c | 1 | ||||
-rw-r--r-- | ipc/mach_msg.c | 2 | ||||
-rw-r--r-- | x86_64/locore.S | 6 |
6 files changed, 11 insertions, 6 deletions
diff --git a/i386/i386/i386asm.sym b/i386/i386/i386asm.sym index 417c040d..9f4ebe55 100644 --- a/i386/i386/i386asm.sym +++ b/i386/i386/i386asm.sym @@ -171,3 +171,5 @@ offset shared_info si evtchn_mask EVTMASK offset shared_info si vcpu_info[0].arch.cr2 CR2 #endif /* MACH_PV_PAGETABLES */ #endif /* MACH_XEN */ + +offset mach_msg_header msgh msgh_size diff --git a/i386/i386/locore.S b/i386/i386/locore.S index 8a1054a6..162bb13a 100644 --- a/i386/i386/locore.S +++ b/i386/i386/locore.S @@ -1314,6 +1314,7 @@ ENTRY(copyinmsg) movl 8+S_ARG0,%esi /* get user start address */ movl 8+S_ARG1,%edi /* get kernel destination address */ movl 8+S_ARG2,%ecx /* get count */ + movl %ecx,%edx /* save count */ movl $USER_DS,%eax /* use user data segment for accesses */ mov %ax,%ds @@ -1325,6 +1326,9 @@ ENTRY(copyinmsg) movsl /* move longwords */ xorl %eax,%eax /* return 0 for success */ + movl 8+S_ARG1,%edi + movl %edx,%es:MSGH_MSGH_SIZE(%edi) /* set msgh_size */ + copyinmsg_ret: mov %ss,%di /* restore DS to kernel segment */ mov %di,%ds diff --git a/include/mach/message.h b/include/mach/message.h index 0a7297e1..30c07296 100644 --- a/include/mach/message.h +++ b/include/mach/message.h @@ -132,7 +132,7 @@ typedef unsigned int mach_msg_size_t; typedef natural_t mach_msg_seqno_t; typedef integer_t mach_msg_id_t; -typedef struct { +typedef struct mach_msg_header { mach_msg_bits_t msgh_bits; mach_msg_size_t msgh_size; mach_port_t msgh_remote_port; diff --git a/ipc/ipc_kmsg.c b/ipc/ipc_kmsg.c index 8f54f81d..4f5ffb5f 100644 --- a/ipc/ipc_kmsg.c +++ b/ipc/ipc_kmsg.c @@ -531,7 +531,6 @@ ipc_kmsg_get( return MACH_SEND_INVALID_DATA; } - kmsg->ikm_header.msgh_size = size; *kmsgp = kmsg; return MACH_MSG_SUCCESS; } diff --git a/ipc/mach_msg.c b/ipc/mach_msg.c index 0ae8fe0c..3a75fef6 100644 --- a/ipc/mach_msg.c +++ b/ipc/mach_msg.c @@ -464,8 +464,6 @@ mach_msg_trap( goto slow_get; } - kmsg->ikm_header.msgh_size = send_size; - fast_copyin: /* * optimized ipc_kmsg_copyin/ipc_mqueue_copyin diff --git a/x86_64/locore.S b/x86_64/locore.S index 612fc493..bbb63252 100644 --- a/x86_64/locore.S +++ b/x86_64/locore.S @@ -1318,6 +1318,7 @@ copyin_fail: */ ENTRY(copyinmsg) xchgq %rsi,%rdi /* Get user source and kernel destination */ + movl %edx,MSGH_MSGH_SIZE(%rdi) /* set msgh_size already */ /* 32 on 64 conversion */ subq $32,%rdx @@ -1330,8 +1331,9 @@ ENTRY(copyinmsg) /* Copy msgh_size */ RECOVER(copyin_fail) lodsl - addl $8,%eax - stosl + /* But don't actually store it: we have already set it above to what we + really copy */ + addl $4,%rdi xorq %rax,%rax /* Copy msgh_remote_port */ |